In a website, I'm using jquery tools.
In a lot of places, I've to do the same action:
When I click on a link, I display a popup:
This is done easily by
$(".overlayTrigger[rel]").overlay({
mask: {
color: '#111',
loadSpeed: 300,
opacity: 0.9
},
closeOnClick: true
}
);
But the problem is that I would like, in each case, call a javascript method which loads some data for my popup.
I know there is a parameter of the trigger that I can set:
onLoad: function() {
//Call the method specified in data-load-method attribute
},
And my goal is to call my custom method in the onLoad: function(){} and the method has to be specified on the <a href> through something like an attribute:
<a href="#" class="overlayTrigger" rel="#MyPopupDiv" data-load-method="LoadPopupXYZData">Click here for the popup</a>
Is there any way to do that?
data-attributes. If yourahas an attribute ofdata-key="hello"you can use$(this).data('key')to get the "hello". See: api.jquery.com/data - Or am I missing something?