Reputation: 345
I have this code and some additional JS should be different for each page loaded. How can i do that? Thanks
function foo(val) {
$("#paginas").hide("fast").load(('profile' + val + '.php'), function () {
//pseudo code
if (page loaded is profile1)
alert("a");
if (page loaded is profile2)
alert("b");
and so on
});
}
for (var i = 0; i < 8; i++) {
$('.lista' + i).bind('click', {
button: i
}, function (event) {
foo(event.data.button);
});
}
Upvotes: 1
Views: 112
Reputation: 32542
You can still access val
from within your ajax .load() function, so you could do:
if(val == 'whatever') {
//do specific thing for "whatever" page
}
Upvotes: 1