Solved

on page added content

Posted on 2014-10-09
1
72 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
The viewer will learn how to dynamically set the form action using jQuery.
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…

920 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

16 Experts available now in Live!

Get 1:1 Help Now