Solved

on page added content

Posted on 2014-10-09
1
74 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
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)

737 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