PDA

View Full Version : How call Jquery function from inside Ajaxtabs loaded content?



tonkon
11-04-2015, 10:46 PM
Hi!

I'm loading products inside the Ajaxtabs plugin.

For each product, I need to add a link or button calling a Jquery ajax function to add this product to a favorite list.

But, the normal click() function from Jquery is not triggered. I found this post at Stackoverflow, but I also was unable to make work... :-(

http://stackoverflow.com/questions/2541328/calling-a-function-defined-in-a-content-page-loaded-by-jquery-tabs

There's some special function to call from inside tabs contents I need to use to call a regular Jquery function?

My simple function:

$(".adiciona_favorito").click(function() {


//var produto_id = $("input.adiciona_favorito").attr("id");
var produto_id = $("a").attr("id");
var dataString = 'produto_id='+ produto_id;
//alert (dataString);return false;
$.ajax({
type: "GET",
url: "favoritos_adiciona.asp",
data: dataString,
success: function(response) {
// Essa linha substitui todo o form para mostrar a msg de retorno
$('#menu_favoritos').html("<div id='menu_favoritos'>" + response + "</div>");
}
});
return false;

});*/

tonkon
11-05-2015, 01:01 AM
Reading the Ajaxtabs docs, I found I need to use the:

instance.onajaxpageload=function(pageurl){
//custom code here
}

Works perfectly!