jquery对话框中的按钮不显示

时间:2021-12-25 22:22:33

I'm trying to have a modal form on a page, for this I am using a jquery dialog. However, the buttons on the dialog don't appear when the form does.

我正在尝试在页面上有一个模态窗体,为此我使用的是jquery对话框。但是,表单上的对话框上的按钮不会出现。

Here is the javascript creating the dialog :

这是创建对话框的javascript:

   function showform() {
  $("#formplan").dialog({
     open: function(event, ui) {
        $(".ui-dialog-titlebar-close").hide();
     },
     modal: true,
     autoOpen: false,
     dialogClass: "dialogform",
     buttons: [{
        text: "Planifier",
        click: function() {
           $("#formplan").dialog("close");
           $("#formplan").submit();
        }
     }, {
        text: "Cancel",
        click: function() {
           $("#formplan").dialog("close");
           $("#formplan").dialog('destroy').remove();
        }
     }]
  });
  $("#formplan").dialog('open');
};

And here is the form included along with the call to the script:

以下是包含对脚本调用的表单:

<div id="formplan" class="dijitDialog" role="dialog" style="display:none">
   <form style="" action="javascript:refreshTab('tabadministrationplanificateurtaches', '/profusion/scheduler/etat.html?onglet=tabadministrationplanificateurtaches&mode=integre&planed=ImportPays ' + getfromform())">
      <br>planification de la tache ImportPays :
      <br>
      <input type="radio" name="periodicity" value="1" checked> tout les jours
      <br>
      <input type="radio" name="periodicity" value="2"> par jours de la semaine :
      <input type="checkbox" name="Daysofweek" value="1"> dimanche
      <input type="checkbox" name="Daysofweek" value="2"> lundi
      <input type="checkbox" name="Daysofweek" value="3"> mardi
      <input type="checkbox" name="Daysofweek" value="4"> mercredi
      <input type="checkbox" name="Daysofweek" value="5"> jeudi
      <input type="checkbox" name="Daysofweek" value="6"> vendredi
      <input type="checkbox" name="Daysofweek" value="7"> samedi
      <br>
      <input type="radio" name="periodicity" value="3"> par mois :
      <input type="text" name="Daysofmonth" placeholder="ex : 1:3:21">
      <br>effectuer à :
      <input type="text" name="hours" placeholder="ex : HH:mm:ss/HH:mm:ss">
      <br> </form>
</div>
<script>
   showform();
</script>

This code is pushed to the HTML using JAVA , so the script calling showform() is there only if needed. Also, I noticed before than I could still click on the page behind, even with the modal:true, and if I clicked on the button generating the page( doing a refresh in the process), my form would appear twice. My guess is that it comes from the call of showform() directly (without being linked to an onclick() event).

使用JAVA将此代码推送到HTML,因此只有在需要时才调用showform()。另外,我之前注意到我仍然可以点击后面的页面,即使使用模态:true,如果我点击生成页面的按钮(在此过程中进行刷新),我的表单将出现两次。我的猜测是它直接来自showform()的调用(没有链接到onclick()事件)。

Thanks,

谢谢,

2 个解决方案

#1


1  

Call your showform() function in javaScript file like this

像这样在javaScript文件中调用showform()函数

 $( document ).ready(function() {
      showform();
  });

jsFiddle link

jsFiddle链接

#2


0  

I moved the id="formplan" from the div to the form and it seemed to do the trick. I also did put the call to showform() in a document.ready() as @zakaria did.

我将id =“formplan”从div移到了表单中,似乎可以解决这个问题。我也确实将调用showform()放在document.ready()中,就像@zakaria那样。

#1


1  

Call your showform() function in javaScript file like this

像这样在javaScript文件中调用showform()函数

 $( document ).ready(function() {
      showform();
  });

jsFiddle link

jsFiddle链接

#2


0  

I moved the id="formplan" from the div to the form and it seemed to do the trick. I also did put the call to showform() in a document.ready() as @zakaria did.

我将id =“formplan”从div移到了表单中,似乎可以解决这个问题。我也确实将调用showform()放在document.ready()中,就像@zakaria那样。