Currently, I have a cached variable, $this
, on which I'm applying .on
to respond to various possible types of behaviour triggers.
$this.on('click','.trigger a',rowTrigger);
$this.on('click','.actions nav a',rowAction);
In the jQuery .on Documentation it doesn't mention if there's a way to combine the above two into a single call. For example, something like this might be nice:
$this.onAny({
click: [
{'.trigger a':rowTrigger},
{'.actions nav a':rowAction}
]
});
Is there a way to achieve this kind of statement (e.g. an existing plugin to extend .on
)?
UPDATE
Use Case (in the current code, prior to a nice solution):
// Plugin 1:
function addTriggers(){
$this.find('td:last').append('<span class="trigger"><a href="#"></a></span>');
return {selector:'.trigger a', event:'click', target: $this, callback: rowTrigger};
}
// Plugin 2:
function addInlineNavigation(){
$navCode = '...'
$this.find('td:last').append('<div class="actions">'+$navCode.html()+'</div>');
return {selector:'.actions nav a', event:'click', target: $this, callback: rowAction};
}