JqueryUI对话框。无法从html表单触发

时间:2010-10-25 18:01:27

标签: jquery-ui modal-dialog

使用文本链接正常工作以触发对话框 - 但如果从html表单提交按钮触发,则持续约0.5秒。听起来很疯狂!是的,只是无法让它工作。救命啊!

  $(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 个答案:

答案 0 :(得分:1)

return false;添加到submitclick处理程序,以防止浏览器提交表单并重新加载页面。

修改

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