我正在尋找避免表單打開兩次的方法。有時可能用戶偶然點擊按鈕兩次>> jQuery表單打開兩次。 如何避免這種情況?避免在按鈕後雙擊打開表單(雙擊)
這裏是我的按鈕:
<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">
此按鈕,點擊後,打開一個jQuery UI的形式。
的按鈕具有類.MaterialNew
形式(如果存在)的ID爲#MaterialNew
感謝您的幫助。
UPDATE
這裏是我的解決辦法,但我不太用它滿足。
// 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; },
...
所以你可以在上面看到,我使用了一個標誌,用於檢查表單是否已經被加載。我不滿意這個解決方案,這是我的看法。也許更好的解決方案是可能的?
謝謝。
我已經試過,並且該按鈕變得'顯然'被禁用(我認爲它好像是這樣),但我仍然可以點擊它並打開jQuery窗體。 – Bronzato 2012-03-25 16:23:06
如果它是一個實際的'
我更新了我的問題,以顯示我目前不滿意的解決方案。 – Bronzato 2012-03-25 18:07:49