Jquery UI对话框中的输入没有被发送? [英] Input inside Jquery UI Dialog not being sent?

查看:109
本文介绍了Jquery UI对话框中的输入没有被发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的对话框中的输入字段没有发布,我不知道为什么...



我已经在mac firefox上测试过它,并且safari和windows IE& firefox的结果相同,所以我不认为它是浏览器,并且如果我禁用了对话框,那么这些字段可以正常显示。



我重新读了jquery ui docs并且无法找到我在做什么错误...对话框似乎不太可能支持输入。



这里是精简版我使用的代码:

 < script type =text / javascript> 
$(document).ready(function(){
$(#dialog)。dialog({
autoOpen:false,
buttons:{
OK:function(){
$(this).dialog('close');
}
}
});
$(#publishSettings ).click(function(){
$(#dialog)。dialog('open');
});
});
< / script>

< form method =POSTaction =publish.php>
< input type =buttonid =publishSettingsvalue =Publish Settings>
< div id =dialog>
发布日期
< input type =textname =publishOn>< br>
取消发布日期
< input type =textname =unPublishOn>
< / div>
< input type =submitname =pubArticlevalue =Publish>
< / form>

没什么特别的,对不对?为什么不能为我工作!?



谢谢!



以下是解决方案:



使用ASP.NET按钮回发的jQuery UI对话



基本上在您的情况下:

  var dlg = $(#对话框)。dialog({
autoOpen:false,
buttons:{
OK:function(){
$(this).dialog('close');
}
}
});
dlg.parent()。appendTo($(#yourformId));

应该解决它。


The input fields in my dialog box aren't being posted, and i'm not sure why...

i've tested it on mac firefox and safari, and windows IE & firefox with the same results, so i don't think it's the browser, and the fields post fine if I disable the dialog box.

I've re-read the jquery ui docs and can't find what i'm doing wrong... It seems unlikely that the dialog box wouldn't support input.

here's a condensed version of the code i'm using:

<script type="text/javascript">
 $(document).ready(function(){
  $("#dialog").dialog({
   autoOpen: false,
   buttons: {
    "OK": function() {
     $(this).dialog('close');
    }
   }
  });
  $("#publishSettings").click(function(){
   $("#dialog").dialog('open');
  });
 });
</script>

<form method="POST" action="publish.php">
 <input type="button" id="publishSettings" value="Publish Settings">
 <div id="dialog">
  Publish Date
  <input type="text" name="publishOn"><br>
  Unpublish Date
  <input type="text" name="unPublishOn">
 </div>
 <input type="submit" name="pubArticle" value="Publish">
</form>

Nothing out of the ordinary, right? Why won't this work for me!?

thanks!

解决方案

When JQuery opens the dialog box , it moves it outside the form.

Here's the solution for that:

jQuery UI Dialog with ASP.NET button postback

basically in your case:

var dlg =  $("#dialog").dialog({ 
   autoOpen: false, 
   buttons: { 
    "OK": function() { 
     $(this).dialog('close'); 
    } 
   } 
  }); 
dlg.parent().appendTo($("#yourformId")); 

should fix it.

这篇关于Jquery UI对话框中的输入没有被发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆