Solution to jqueryeasyui failure in UpdatePanel _ jquery

Source: Internet
Author: User
UpdatePanel and jquery-easyui are used in the project. The advantage of using updatepanel is that the page is not refreshed, and the user feels better, while also reducing the transmission of some data. The advantages of easyui are not only the interface but also the convenience of use.

The Code is as follows:



...


...


...




You only need to define a corresponding class for him to achieve various effects.

However, if you put it in updatepanel, and it is not the first time that it is displayed, it will cause a fault.

The Code is as follows:






...



...



...







...



...



...






Define two identical views in the multipleView, with the same content. Put MultiView1 in updatepanel.

Then set it to display the first view

The Code is as follows:


MultiView1.ActiveViewIndex = 0;


Browse. Displayed normally. But when we change the display of the view, for example, change the above to MultiView1.ActiveViewIndex = 1; then the effect of the second veiw will be completely lost.

Find the cause in jquery. easyui. min. js. See this sentence

The Code is as follows:


R = $ (". easyui-tabs", _ 1ec );
If (r. length ){
R. tabs ();


After the webpage is loaded, find the layer of the class defined as easyui-tabs. And attach the effect to him.

As you can imagine, when a page is loaded, We will display the first view, so js will find the layer in the view and give it the effect.
Then we updated the displayed view in updatepanel, although the content was switched to the second view. However, the page is not reloaded, and the above js Code does not change the execution of the new view.
Therefore, the decision is to re-execute the js Code after the updatepanel is sent back.
Define a rebinding function on the page.

The Code is as follows:


Function EndRequestHandler (){
$ (". Easyui-tabs"). tabs ();
}


Define another event.

The Code is as follows:


Function reload (){
Sys. WebForms. PageRequestManager. getInstance (). add_endRequest (EndRequestHandler );
}


Add_endRequest
The PageRequestManager class is used to manage the partial page update of the server UpdatePanel control in the browser. In addition, some attributes, events, and methods are defined to customize webpages through client scripts. Call the getInstance method to obtain the PageRequestManager class instance. Then, use the add_endRequest method to bind the endRequest event (asynchronous sending is completed, and the control is triggered after the return to the browser ). In this way, the EndRequestHandler () function will be triggered every time the updatepanel callback occurs. Rebind the effect once. $ (Document). ready (function () {reload ();})
The failure problem is solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.