tags:

views:

88

answers:

2

I am trying to change the left position for a dialog box created with jQuery, but it does not seems to recognize the new value; here is my code:

   $('#settype_dialog').dialog({
           autoOpen: true,
           width: 200,
           height: 200,
           show: 'bounce',
           hide: 'puff'
          }
   );
   $('#settype_dialog').css({"left", cX});
   $('#settype_dialog').dialog('option', 'title', 'Select Set Type');
   $('#settype_dialog').html(xml_text);
   $('#settype_dialog').dialog('open');

Where cX is 130

A: 

You need to append "px". cX + "px"

Chetan Sastry
Nah. If a number value is passed in, the CSS method automagically adds the `px` suffix. See lines 42-44 of http://dev.jquery.com/browser/trunk/jquery/src/css.js
jason
Hmm. Interesting to know. Thanks!
Chetan Sastry
+1  A: 

Well, incorrect syntax looks to be the cause of your problem. The css() method of the jQuery object accepts either an object of key/value pairs where key is the property, or a property, value signature.

The two following ways would be equivalent:

$('#settype_dialog').css({"left": cX});

or

$('#settype_dialog').css("left", cX);
jason