0

I'm just trying to play around with Jquery dialog. I click a button and the dialog appears. This code is just straight copy from Jquery docs (well, through a link to a blog post).

<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js"></script>
<script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquery.validate.min.js"></script>
<script type="text/javascript">

var js = jQuery.noConflict();

js(document).ready(function() {
var $dialog = js('<div></div>')
    .html('This dialog will show every time!')
    .dialog({
        autoOpen: false,
        title: 'Basic Dialog'
    });

js('#axis-details').click(function() {
    $dialog.dialog('open');
    // prevent the default action, e.g., following a link
    return false;
});
});
</script>

The simple html button:

<button id="axis-details" >API Key</button>

I get this error: js("<div></div>").html("This dialog will show every time!").dialog is not a function

First I want to make sure I didn't do anything wrong with the code here. Typically this means it is not loading the jquery-ui appropriately but I can see with firebug it is loaded fine. I also make sure it doesn't conflict with any other package, hence the noConflict().

Any hints where I'm going wrong would be appreciated.

4
  • 1
    Seems to be some bugs with using .noConflict(), especially with jQuery UI. Check out the comments at the bottom of the api page for noConflict: api.jquery.com/jQuery.noConflict Commented Mar 5, 2012 at 20:46
  • 2
    sounds like you may be loading jQuery again in page somewhere else, which will wipe out jQueryUI being part of jQuery object Commented Mar 5, 2012 at 20:48
  • 2
    Yes, your code works fine when isolated: jsfiddle.net/JvuY7 Commented Mar 5, 2012 at 20:48
  • Thanks all, @Travis J is right. There is some sort of conflict. Commented Mar 6, 2012 at 1:21

2 Answers 2

2

copied to JSFiddle

And it works fine. Your problem must be outside of this bit of code

Sign up to request clarification or add additional context in comments.

Comments

1

@Travis J had this right. Seems like there is some sort of conflict with .noConflict() and jQuery UI. How ironic ;)

Removing noConflict() makes this work.

Comments

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.