1

I have this aspx page:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Some Title</title>
    <link href="css/home.css" rel="stylesheet" />
    <script src="js/jQuery.js"></script>
    <script src="js/dragBar.js"></script>
</head>
<body>
<div id="content">
    <div id="map">
        <iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.za/maps/ms?msa=0&amp;msid=208869092274662645717.0004dd2a2065f7b179e5b&amp;hl=en&amp;ie=UTF8&amp;ll=-25.401819,28.721652&amp;spn=0,0&amp;t=m&amp;output=embed">
        </iframe>
        <div id="dragbar"></div>
    </div>
    <div id="main">
        <asp:Label ID="lblError" runat="server" Text="Label"></asp:Label>
    </div>
</div>

This is my CSS:

#content {
    position: relative;
    height: auto;
    width: 1000px;
    margin: auto;
    padding-top: 150px;
    z-index: 2;
    background-color: white;
    border-left: 1px solid black;
    border-right: 1px solid black;
}

#content iframe {
    position: relative;
    top: 0px;
    left: 0px;
    width: 100%;
    height: 100px;
    min-height: 200px;
    border-bottom: 1px solid black;
    box-shadow: 0px 0px 10px black;
}

#content #main {
    background-color: BurlyWood;
    position: relative;
    width: 1000px;
    height: 200px;
    right: 0;
    left: 0px;
    z-index: 0;
}

#content #map {
    background-color: IndianRed;
    width: 1000px;
    height: auto;
    position: relative;
    top: 0px;
    bottom: 38px;
    overflow-y: hidden;
    z-index: 1;
}

#content #dragbar {
    background-color: black;
    position: absolute;
    bottom: 0px;
    width: 100%;
    height: 3px;
    cursor: row-resize;
    z-index: 1000;
}

And this is my jQuery:

$('#dragbar').mousedown(function (e) {
    e.preventDefault();
    $(document).mousemove(function (e) {
        $('#main').css("top", e.pageY);
        $('#dragbar').css("bottom", 0);
        $('iframe').css("height", e.pageY - 10);
    });
});

$(document).mouseup(function (e) {
    $(document).unbind('mousemove');
});

My problem is that this works on jsFiddle when I type the code, but this is not working in Visual Studio 2012. Is there something I am missing?

Sorry, Forgot about the problem. My problem is that it should resize the map div and the iframe inside it when I drag the dragbar div.

My JFiddle location: http://jsfiddle.net/Bebbie7/QGK5N/

3
  • What are you expecting to happen? Commented May 21, 2013 at 11:53
  • 2
    you are missing a better explanation of your problem! Commented May 21, 2013 at 11:58
  • Is this exactly what you have in your asp.net page, because if any of those items you reference by ID are asp.net runat=server controls, their client ID will be different in the browser than the asp.net page and your jquery selectors will not find them. View the source code in your asp.net page in the browser and check! Commented May 21, 2013 at 12:41

1 Answer 1

1

The main difference between jsFiddle and VisualStudio is how the scripts are being included. First, make sure jquery is being loaded correctly (paths are correct etc) by running the script debugger or adding an alert. Second, try wrapping your script in an OnReady handler to make sure everything is finished loading before executing:

$( document ).ready(function() {
    alert("jQuery is working");

    $('#dragbar').mousedown(function (e) {
        e.preventDefault();
        $(document).mousemove(function (e) {
            $('#main').css("top", e.pageY);
            $('#dragbar').css("bottom", 0);
            $('iframe').css("height", e.pageY - 10);
        });
    });

    $(document).mouseup(function (e) {
        $(document).unbind('mousemove');
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, did not realize... all I added was: $( document ).ready(function() {. Now its working. Thank you my man!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.