简体   繁体   English

按钮单击时jQuery jQuery UI的功能不起作用

[英]jQuery dialog ui on button click with function not working

I am trying to get the following logic to work. 我正在尝试使以下逻辑起作用。 Any suggestions would be greatly appreciated. 任何建议将不胜感激。

here is what I'm trying to do.. 这就是我想要做的..

if <input type="button" name="filter" id="filter" value="Save / Change" /> is clicked. 如果<input type="button" name="filter" id="filter" value="Save / Change" />

then check if requiredFields() returns true 然后检查requiredFields()是否返回true

if requiredFields() returns true 如果requiredFields()返回true

then display jQuery UI dialog 然后显示jQuery UI对话框

from jQuery dialog action 从jQuery对话框动作

set form field, change form action, submit form, change form action back to original action 设置表单字段,更改表单操作,提交表单,将表单操作更改回原始操作

 jQuery(function($)
 {
 $("#filter").on("click", function() {

    if(requiredFields()) {
      $("#dialog").dialog("open");
      $( "#dialog" ).dialog({
        resizable: false,
        height:175,
        modal: true,
        position: {
          my: "center top",
          at: "center top",
          of: window
        },
        buttons: {
          "Yes": function() {
            $( this ).dialog( "close" );

            $('input[name="setAccess"]').val('1');

            $("#myForm").attr("action", "submit.epl");
            $( "form:myForm" ).submit();
            $("#myForm").attr("action", "form.epl");


          },
          "No": function() {
            $( this ).dialog( "close" );

            $('input[name="setAccess"]').val('');

            $("#myForm").attr("action", "submit.epl");
            $( "form:myForm" ).submit();
            $("#myForm").attr("action", "form.epl");

          }
        }
      });
    }
 });
});

Here is Fiddle demo 这是小提琴演示

I would suggest to change your workflow a bit... I would suggest to initialize modal dialog immediately on document ready event with autoOpen: false and later just use $("#dialog").dialog("open"); 我建议稍微改变您的工作流程...我建议立即使用autoOpen: false在文档就绪事件上初始化模式对话框autoOpen: false ,稍后再使用$("#dialog").dialog("open"); method to open it. 打开它的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM