I’m looking for a way to avoid a form to be opened twice. Sometimes it may be possible the user incidentally click the button twice >> the jQuery form is opened twice. How to avoid this?
Here is my button:
<a class="dialogLink MaterialNew ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary" role="button" aria-disabled="false" href="/PLATON/Material/_MaterialEditNew?requestID=10" data-update-url="/PLATON/Material/_MaterialList?requestID=10" data-update-target-id="MaterialList" data-dialog-title="Ajouter un matériel à transporter" data-dialog-id="MaterialNew">
This button, when clicked, open a jQuery UI form.
The button has the class .MaterialNew
The form (if exist) has the id #MaterialNew
Thanks for your help.
UPDATE
Here is my solution but I’m not quite satisfy with it.
// Flag to avoid form to be loaded twice
var formLoaded;
// Wire up the click event of any current or future dialog links
$('.dialogLink').live('click', function () {
if (formLoaded)
return false;
else
formLoaded = true;
....
$(dialogDiv).load(this.href, function () {
$(this).dialog({
modal: true,
close: function () { $(this).dialog('destroy').remove(); formLoaded = false; },
...
So as you can see above, I used a flag for checking whether the form is already loaded. I’m not satisfy with this solution, that’s my opinion. Maybe a better solution is possible?
Thanks.
Had the same problem : form was opening twice in IE after clicking on the button.
Simply adding a “return false;” statement after loading the form did the trick.