2010-10-25 77 views
0

可以正常使用文本鏈接來觸發對話框 - 但如果從HTML表單提交按鈕觸發,則持續約0.5秒。聽起來很瘋狂!是的,只是無法讓它工作。幫幫我!JqueryUI對話框。無法從HTML表單中觸發

$(document).ready(function() { 
    $('#rating-0').click(function() { $('#dialog').dialog('open'); }); $('#dialog').dialog({ autoOpen: false, height: 280, modal: true, resizable: false, buttons: { Continue: function() { 
     $(this).dialog('close'); // Submit Rating 
    }, 'Change Rating': function() { 
     $(this).dialog('close'); // Update Rating 
    } } 
    }); 
    }); 

<form action="https://www.etc" id="rating-0"> 
    <input type="hidden" name="cmd" value="_s-xclick" /> 
    <input name="submit" type="image" src="https://www.paypal.com/en_GB/i/btn/btn_cart_LG.gif" /> 
</form> 
<div id="dialog" title="Are you sure?"> 
    <p>You've assigned the current celebrity a rating of 0…</p> <p>Perhaps you are just judging them on the terrible last movie…</p> 
</div> 
+1

可否請你發佈一些標記?如果我們看不到你做了什麼,它很難提供幫助。 ('#rating-0')。click(function(){('#dialog')。dialog('open'); }); ( – Brandon 2010-10-25 18:03:26

+0

)$(document).ready(function(){。 $( '#對話')對話框({ 的AutoOpen:假的, 高度:280, 模式:真, 可調整大小:假的, 按鈕:{ 繼續:函數(){$ (本).dialog ( '親密'); // 提交評分 }, '更改評級':函數(){$ (本).dialog( '親密'); // 更新評級 }} }); }); – Rosy 2010-10-25 18:17:51

+0

\t \t

You've assigned the current celebrity a rating of 0…

Perhaps you are just judging them on the terrible last movie…

Rosy 2010-10-25 18:20:39

回答

1

添加return false;到您的submitclick處理程序,以防止瀏覽器提交表單並重新加載頁面。

編輯

$(document).ready(function() { 
    $('#rating-0').submit(function() { 
     $('#dialog').dialog('open'); 
     return false; 
    }); 
    ... 
    }); 
+0

由於Slaks。我需要更多的幫助!我不太會用jquery ..我應該在哪裏插入'return false'..請參閱上面的腳本。謝謝 – Rosy 2010-10-25 18:29:22

+0

Slaks。你是一個創業板!作品一種享受。非常感謝。 Rosyx – Rosy 2010-10-25 21:14:36

+0

@Rosy:你應該通過點擊空格檢查來接受這個答案。 – SLaks 2010-10-25 23:59:03