-1

I have modal dialog. I want to position it according to variable that i get. I just concerned on Y-position and for X-position I just put 'middle' and it's worked.

Is it possible for me to put variable in my modal window position just like my last line?

My idea is where ever user click, the modal dialog will appear upper the clicked position

here is how i get the y-position (onclcick)

var curr = e.pageY - $(window).scrollTop();
$('#spnCursor').val(curr); 

This code to get the variable value

$(function() {  
var cursor = $('#spnCursor').val();
var msgposition = cursor - 300;

$( "#dialog-form" ).dialog({
  position: ['middle','msgposition'],

Thanks.

Satpal
  • 132,252
  • 13
  • 159
  • 168
user2699175
  • 929
  • 2
  • 9
  • 16

1 Answers1

0

You should remove the quotes around the msgposition variable like this:

$( "#dialog-form" ).dialog({
    position: ['middle', msgposition],
});

EDIT:

If above does not work then you should try,

$( "#dialog-form" ).dialog( 'option', 'position', [myDialogX, myDialogY] );

Also you can have a look at the documentation on Dialog Widget and jQuery UI dialog positioning might be helpful to you as well.

Community
  • 1
  • 1
Subedi Kishor
  • 5,906
  • 5
  • 35
  • 53