Reputation: 969
I am successfully opening a JQuery dialog modal. My first JQuery function opens dialog and my second jquery function set the dialog position to top. I want to merge these two functions, please see my following code:-
$(function () {
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true
});
$('#modal-registration').dialog({ position: 'top' });
});
In above code how can i merge these two functions like $("#modal-registration").dialog({autoOpen:false, et:cetera})
and the $('#modal-registration').dialog({ position: 'top' });
with each other?, thanks.
Upvotes: 0
Views: 68
Reputation: 81
As per your fiddle link, you can do following :
$( "#dialog" ).dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position : [0,0] //mention the attribute here itself
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
Its working fine.
Upvotes: 0
Reputation: 3662
<button id="opener">open the dialog</button>
<div id="dialog" title="Dialog Title">I'm a dialog</div>
$('#dialog').dialog( 'option', 'position', [0, 0] );
change [0,0] to x,y coordinates of your need
Upvotes: 0
Reputation: 7159
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position: 'top'
})
Why not in single command?
Upvotes: 0
Reputation: 3999
Can you not just stick the position property in with the first dialog call? Like
$("#modal-registration").dialog({
autoOpen: false,
height: 400,
width: 380,
model: true,
position: 'top'
});
Upvotes: 1