Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/425.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
触发一个javascript函数_Javascript_Jquery_Jquery Ui - Fatal编程技术网

触发一个javascript函数

触发一个javascript函数,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我想在yes-no逻辑中触发一个对话框模式消息脚本。 目前它在onclick事件中工作。例如: 如果我的逻辑是真的,我希望它自动执行(无需任何点击) 例如: 如果逻辑为真,则执行 <script> $(function() { $( "#dialog-message" ).dialog({ modal: true, buttons: { Ok: function() { $( this ).dialog( "close" );

我想在yes-no逻辑中触发一个对话框模式消息脚本。 目前它在
onclick
事件中工作。例如:

如果我的逻辑是真的,我希望它自动执行(无需任何点击)

例如:

如果逻辑为真,则执行

<script>
$(function() {
  $( "#dialog-message" ).dialog({
    modal: true,
    buttons: {
      Ok: function() {
       $( this ).dialog( "close" );
      }
    }
  });
});
</script>

$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
有什么想法吗?


<script>
$(function() {
  $( "#dialog-message" ).dialog({
   modal: true,
   buttons: {
      Ok: function() {
         $( this ).dialog( "close" );
      }
   }
  });

  if ( condition ) 
     $( "#dialog-message").dialog('open');
});
</script>
$(函数(){ $(“#对话框消息”).dialog({ 莫代尔:是的, 按钮:{ 好的:函数(){ $(此).dialog(“关闭”); } } }); 如果(条件) $(“#对话框消息”).dialog('open'); });
这就是用条件调用它的方式。


$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
如果(条件)
$(“#对话框消息”).dialog('open');
});
这就是用条件调用它的方式。


$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
如果(条件)
$(“#对话框消息”).dialog('open');
});
这就是用条件调用它的方式。


$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
如果(条件)
$(“#对话框消息”).dialog('open');
});
这就是你可以用条件来称呼它的方式。

为什么不呢

<script>
var myFunc = $(function() {
    $( "#dialog-message" ).dialog({
        modal: true,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
           }
       }
    });
});


$(document).ready(function() {
    // Edit after comments
    $(document).on('some-selector', 'some-event', function() {
        if (/* your logic is true */) {
            myFunc();
        }
    }
 });

</script>

var myFunc=$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
$(文档).ready(函数(){
//评论后编辑
$(文档).on('some-selector','some-event',function(){
如果(/*您的逻辑为真*/){
myFunc();
}
}
});
为什么不呢

<script>
var myFunc = $(function() {
    $( "#dialog-message" ).dialog({
        modal: true,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
           }
       }
    });
});


$(document).ready(function() {
    // Edit after comments
    $(document).on('some-selector', 'some-event', function() {
        if (/* your logic is true */) {
            myFunc();
        }
    }
 });

</script>

var myFunc=$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
$(文档).ready(函数(){
//评论后编辑
$(文档).on('some-selector','some-event',function(){
如果(/*您的逻辑为真*/){
myFunc();
}
}
});
为什么不呢

<script>
var myFunc = $(function() {
    $( "#dialog-message" ).dialog({
        modal: true,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
           }
       }
    });
});


$(document).ready(function() {
    // Edit after comments
    $(document).on('some-selector', 'some-event', function() {
        if (/* your logic is true */) {
            myFunc();
        }
    }
 });

</script>

var myFunc=$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
$(文档).ready(函数(){
//评论后编辑
$(文档).on('some-selector','some-event',function(){
如果(/*您的逻辑为真*/){
myFunc();
}
}
});
为什么不呢

<script>
var myFunc = $(function() {
    $( "#dialog-message" ).dialog({
        modal: true,
        buttons: {
            Ok: function() {
                $( this ).dialog( "close" );
           }
       }
    });
});


$(document).ready(function() {
    // Edit after comments
    $(document).on('some-selector', 'some-event', function() {
        if (/* your logic is true */) {
            myFunc();
        }
    }
 });

</script>

var myFunc=$(函数(){
$(“#对话框消息”).dialog({
莫代尔:是的,
按钮:{
好的:函数(){
$(此).dialog(“关闭”);
}
}
});
});
$(文档).ready(函数(){
//评论后编辑
$(文档).on('some-selector','some-event',function(){
如果(/*您的逻辑为真*/){
myFunc();
}
}
});

您想在页面加载时运行它?还是在其他事件上运行它?只需将其设置为函数并调用它。您想在页面加载时运行它?还是在其他事件上运行它?只需将其设置为函数并调用它。您想在页面加载时运行它?还是在其他事件上运行它?只需将其设置为函数并调用它。您想在页面加载时运行它?还是在其他事件上运行它r事件?只要把它变成一个函数并调用它。那不是初始化一个新对话框吗?我是说,没有任何属性集。那不是初始化一个新对话框吗?我是说,没有任何属性集。那不是初始化一个新对话框吗?我是说,没有任何属性集。那不是初始化一个新对话框吗?我是说,没有任何属性集。