This is a big problem to me for long time in JQuery. I downloaded the Jquery UI min file and started using in my projects. On the way, there are some requirements where I need to show the dialog box and execute some logic. But, whenever I click some button to open a dialog, very first time only it opens like a charm. From the time when I close it, it will never open again by clicking on open dialog link. This gave me lot of frustration and I don’t know where the exact problem is. After reading all the documentation in JQuery docs, finally found the problem and fixed it in seconds.
Solution:
$("#dialog").dialog({ modal: true, resizable: false,
draggable: false, width: 515, height: 245 });
$("#dialog").dialog('open');
I know everyone is declaring only the first statement in their code and no one will write the second statement to open the dialog. Below is the explanation for it.
As far as I understood, what JQuery framework doing internally is, When we write the first statement, it is treating it as the initiation of the dialog for the div or HTML control. Because of adding "model:true", it will open for the first time, when you click on a link and never open again once you closed. Because no where we mentioned to open the dialog in the first statement.
And about second statement, JQuery is calling the dialog property and forcibly loading the dialog to the DOM and shows it on the screen. So, open property/attribute will do the trick. So, whenever you want to use a dialog box in JQuery, this is the code you need to use to open it as many times as you want.
Is this what you are looking for? Or do you know any other ways to implement it? Please post all your ideas here.
No comments:
Post a Comment