当页面刷新时,Jquery只工作一次,但其他时候不工作 [英] Jquery works only once when page is refresh but not the other times

查看:40
本文介绍了当页面刷新时,Jquery只工作一次,但其他时候不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从过去三天以来,我无处可去。



我有一个网站,右栏和左栏和中心区。在右栏中,我有不同标准的学生搜索。

我有一个按钮LoadSearch,它在Right列上加载我的用户控件。

所有与Right列相关的脚本都放在StudenSearches.js文件中。

我的document.ready如下,它加载我的搜索并根据其他选择加载我的选择选项。然而,这只能工作一次......第一次刷新页面时这很有效。首次单击加载搜索按钮时,它会加载我的所有选择选项。当第二次点击时它没有加载选择选项。





I am going nowhere with this since last three days.

I have a website with Right column and left column and center area. On the Right column I have Student searches with different criteria.
I have button "LoadSearch" that loads my user controls on Right column.
All the scripts related to Right column are placed StudenSearches.js file.
My document.ready is as follows, which loads my searches and loads my select options based on other selections. However this works only once ... the first time page is refreshed this works amazing. When first clicked on Load search button, it loads all my select options. When clicked on second time it doesn't load the select options.


$(document).ready(function (){

    $(":input", GetSubjectSearch()).bind("keydown", function () {  setTimeout(function() { SubjectChange(this); }, 4); })
	.bind("change", function() { setTimeout(function() { SubjectChange(this); }, 4); });

  
    
    $(":input", GetwildSearch()).bind("keydown", function() { setTimeout(function() { wildSearchChange(this); }, 4); })
	.bind("change", function() { setTimeout(function() { wildSearchChange(this); }, 4); })
	.bind("paste", function() { setTimeout(function() { wildSearchChange(this); }, 4); });

    
    GetYear().bind("change", function() { YearChange(this); });
    GetDepartment().bind("change", function() { DepartmentChange(this); });
    GetBranch().bind("change", function() { BranchChange(this); });
    GetClass().bind("change", function() { ClassChange(this); });
    GetSection().bind("change", function() { SectionChange(this); });

   
    $("#btnNew").button().click(ShowNewcontents);
	});







document.ready区域中的那些函数初始化我的选择选项。所以例如




Those functions in document.ready area stuff that initializes my select options. So Forexample

Year Deapartment
      Branch class







是执行document.ready时加载的四个选项。现在在按钮单击事件上,我必须重新加载document.ready中的所有内容。所以我创建了一个函数,并在按钮的单击事件上调用它。但是,当我第二次点击按钮时它没有加载我的选择选项,因为页面没有在该点击上刷新



我尝试了什么:



我试过windows.load,widnows.addeventlistener,什么不是。但似乎没有任何东西在没有页面被刷新的情况下第二次工作。



如果有人可以帮助我,我真的很感激




are four select options that gets loaded when document.ready is executed. Now on a button click event, I have to reload everything in document.ready. So I created a function and called that on click event of button. However it doesn't load my select options when I click button for second time because page is not being refreshed on that click

What I have tried:

I have tried windows.load, widnows.addeventlistener and what not. But nothing seems to be working on second time without page being refreshed.

I really appreciate if someone can help me in this

推荐答案

(document).ready(function(){
(document).ready(function (){


(:input,GetSubjectSearch())。bind(keydown,function(){setTimeout (function(){SubjectChange(this);},4);})
.bind(change,function(){setTimeout(function(){SubjectChange(this);},4);}) ;
(":input", GetSubjectSearch()).bind("keydown", function () { setTimeout(function() { SubjectChange(this); }, 4); }) .bind("change", function() { setTimeout(function() { SubjectChange(this); }, 4); });


(:input,GetwildSearch())。bind(keydown,function(){setTimeout(function(){wildSearchChange(this);},4);} )
.bind(change,function(){setTimeout(function(){wildSearchChange(this);},4);})
.bind(paste,function(){setTimeout (function(){wildSearchChange(this);},4);});


GetYear()。bind(change,function(){YearChange(this);} );
GetDepartment()。bind(change,function(){DepartmentChange(this);});
GetBranch()。bind(change, function(){BranchChange(this); });
GetClass()。bind(change,function(){ClassChange(this);});
GetSection()。bind(change,function(){SectionChange(this);});
(":input", GetwildSearch()).bind("keydown", function() { setTimeout(function() { wildSearchChange(this); }, 4); }) .bind("change", function() { setTimeout(function() { wildSearchChange(this); }, 4); }) .bind("paste", function() { setTimeout(function() { wildSearchChange(this); }, 4); }); GetYear().bind("change", function() { YearChange(this); }); GetDepartment().bind("change", function() { DepartmentChange(this); }); GetBranch().bind("change", function() { BranchChange(this); }); GetClass().bind("change", function() { ClassChange(this); }); GetSection().bind("change", function() { SectionChange(this); });


这篇关于当页面刷新时,Jquery只工作一次,但其他时候不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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