我的jQuery选择不在内容页更新面板后工作 [英] My jquery selectors doesn't work after update panel in content page
问题描述
我有一个内容页,我写ASP经过一番jQuery选择:的UpdatePanel,对于第一次,当加载页面
$(文件)。就绪(函数()的作品的权利,但回传后,选择不工作了,没有办法确实存在解决这个问题?
< ASP:内容ID =内容1contentplaceholderid =contentplaceholder1=服务器>
< ASP:的UpdatePanel ID =UpdatePanel1=服务器>
<&的ContentTemplate GT;
< ASP:文本框ID =txtdate=服务器的CssClass =persianDTP>< / ASP:文本框>
<! - 约code - > < /&的ContentTemplate GT;
< / ASP:的UpdatePanel> <脚本>
$(文件)。就绪(函数(){
$('。PersianDTP')。日期选择器({
showOn:按钮,
按钮画面:calendar.png',
DATEFORMAT:'YY / MM / DD',
// AppendText通过:(YY / MM / DD),
changeMonth:真实,
changeYear:真实,
// selectOtherMonths:真实,
// showOtherMonths:真实,
showStatus:真实,
showButtonPanel:真实,
buttonImageOnly:真实,
buttonText:选择日期,
的OnClose:函数(){
this.focus();
}
}); jQuery的(函数($){
$(PersianDTP)掩码(9999/99/99);
}); });
< / SCRIPT>
< / ASP:内容>
我发现我的问题的回答结果
规范。从亲爱的[jquerybyexample] [1]结果坦
http://www.jquerybyexample.net/2010 /07/jquery-does-not-work-properly-after.html
[1]: https://plus.google.com/110764258896584230255 搜索结果
创建一个js文件巫婆包含乌尔选择并使用此功能结构:)结果
每一个地方ü需要这种选择使用他们的脚本标签,尽情享受吧! :)结果
//在内容页
<脚本类型=文/ JavaScript的SRC =ur_path>
< / SCRIPT> //在js文件
$(文件)。就绪(函数(){
。Sys.WebForms.PageRequestManager.getInstance()add_endRequest(EndRequest);
功能EndRequest(发件人,参数)
{
如果(args.get_error()==未定义){
BindEvents();
}
}
功能BindEvents()
{
// UR选择会坐在这里
$('文件')。就绪({
//乌尔jQuery的code
}
});
} BindEvents(); });
i have a content page, i write some jquery selectors after asp:updatepanel, for first time, when page loaded $(document).ready(function() works right, but after a postback, selectors doesnt work anymore, any way does exist to solve this problem??
<asp:content id="Content1" contentplaceholderid="contentplaceholder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtdate" runat="server" CssClass="persianDTP" ></asp:TextBox>
<!-- some code -->
</ContentTemplate>
</asp:UpdatePanel>
<script>
$(document).ready(function () {
$('.PersianDTP').datepicker({
showOn: 'button',
buttonImage: 'calendar.png',
dateFormat: 'yy/mm/dd',
//appendText: ' (yy/mm/dd)',
changeMonth: true,
changeYear: true,
//selectOtherMonths: true,
//showOtherMonths: true,
showStatus: true,
showButtonPanel: true,
buttonImageOnly: true,
buttonText: 'Choose a Date',
onClose: function () {
this.focus();
}
});
jQuery(function ($) {
$(".PersianDTP").mask("9999/99/99");
});
});
</script>
</asp:content>
i found my problem's answer
spec. tanx from dear [jquerybyexample][1]
http://www.jquerybyexample.net/2010/07/jquery-does-not-work-properly-after.html
[1]: https://plus.google.com/110764258896584230255
create a js file witch contains ur selectors and use this functional structure :)
every where u need this selectors use them from script Tag, enjoy it! :)
//in content page
<script type="text/javascript" src="ur_path">
</script>
//in js file
$(document).ready(function () {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
function EndRequest(sender, args)
{
if (args.get_error() == undefined) {
BindEvents();
}
}
function BindEvents()
{
// ur selectors will sit here
$('document').ready({
//ur jquery code
}
});
}
BindEvents();
});
这篇关于我的jQuery选择不在内容页更新面板后工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!