This topic is locked

Target Dom Elements After They Are Loaded Via Ajax (Jcade Plugin)

1/17/2013 4:50:37 PM
PHPRunner Tips and Tricks
F
FunkDaddy author

Go to: https://github.com/snesin/jcade'>https://github.com/snesin/jcade
Insert a reference to it either via visual editor or insert php snippet immediately after header element:



//Inserted via php snippet immediately after header

echo '<script src="custom_files/plugins/jcade-master/jcade.js"></script>';


Now in page where the AJAX call is taking place behind the scenes you can target elements so one they are created via the AJAX response you can target them. Otherwise, without this it is very difficult to make any reference to newly added elements created on that page.
For example, add this to your JS OnLoad event of the page that contains the ajax call:


//https://github.com/snesin/jcade'>https://github.com/snesin/jcade

$(document).create( "#my_special_field_label_id",function(event) {

$('#my_special_field_label_id').text('New Field Label');//This changes the field label dynamically (assuming field was created via ajax in that page)

});


You can target any other element using standard Jquery selectors (tag name, class, etc).

F
FunkDaddy author 12/5/2013

I happened to stumble upon my own post here and realized I found another plugin that performs the same thing, but perhaps even more powerful overall (Jquery LiveQuery): https://github.com/brandonaaron/livequery
Just thought I'd share it :-)