Solved

on page added content

Posted on 2014-10-09
1
70 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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

by Julian Matz As of jQuery (http://jquery.com/) 1.4 the .live() method (http://api.jquery.com/live/) supports custom events as well as some standard JavaScript events that it previously didn't support. Among these is the submit event. Unlike …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now