2

I'm migrating some old code to jquery:

 xmlHttp.onreadystatechange = function() {
  if (xmlHttp.readyState == 4) {
   $("#" + ajaxArea).html (xmlHttp.responseText);

   $("#" + ajaxArea).attr('title', 'Login');
   $("#" + ajaxArea).dialog({
    height : 140,
    modal : true
   });
  }
 };

where ajaxArea is the ID of a DIV in the HTML.

The dialog bit is basically adapted from the jQuery example here: http://jqueryui.com/demos/dialog/#modal

All of it works fine up until the last line. Firefox throws an error that simply says "$(" for that line. Anyone know what might be causing this?

2
  • 3
    Are you sure you're importing both jQuery and the jQuery UI "dialog" files? Commented May 31, 2010 at 14:33
  • Ah... didn't realise there was a seperate file for the UI stuff, thank you! Commented May 31, 2010 at 14:39

1 Answer 1

2

The jQuery UI code is separate from "core" jQuery. You can import both into your application from Google's servers:

You can alternatively build your own custom jQuery UI package, which will be smaller (but not hosted at Google). That's done at the jQuery UI site itself: http://jqueryui.com/download

As a style note, it's good to get in the habit of using jQuery's "chaining" style:

$("#" + ajaxArea).html (xmlHttp.responseText)
  .attr('title', 'Login')
  .dialog({
    height : 140,
    modal : true
  });

It saves some work, esp. when the selector is complicated.

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

1 Comment

The links in my answer here are out of date. Check code.google.com/apis/libraries for the real beef.

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.