Solved

on page added content

Posted on 2014-10-09
1
73 Views
Last Modified: 2014-10-17
I have a function which adds action events onto classes, however I pull in data from ajax calls very rarely redrawing the entire page. Currently at the end of each ajax event I call a function doOnLoad() and in there I do all the changes. For example everything with the .tabbed class gets drawn into a tabbed view. Instead of putting this line in is there an event that when the page has content added a function can be called?
0
Comment
Question by:tonelm54
1 Comment
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 40370127
The safest and transparent way is as you're doing it.
I don't like to hide things behind the scenes that will be later harder to understand and debug.

Anyway, the alternative is to catch all the ajax responses (successes) and act upon.
Here's the jquery documentation for it: http://api.jquery.com/ajaxSuccess/

The basic idea it to attach an ajaxSuccess event handler to the page document.
Here's a snippet taken from the doc:
$(document).ajaxSuccess(function() {
  // probably you need to validate is the ajax request is the one you want and...
  doOnLoad();
});

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question