tags:

views:

79

answers:

2

Is there a way to apply plugin to element in a "live" fashion, just like we can attach handler that survives ajax calls? Right now we have some code that uses "cluetip" in a rad grid, but after ajax, it gets dropped.

$('a.clickableSticky').cluetip({
                    splitTitle: '|',
                    showTitle: false,
                    titleAttribute: 'description',
                    activation: 'click',
                    sticky: true,
                    arrows: true,
                    closePosition: 'title'
                });
+1  A: 

Live only works on events, so you can't do it with clue tip.

You can still run cluetip on any newly created elements though.

So...

$('#grid').live('gridRefreshEvent', function () {
 $('#grid').find('a.clickableSticky').cluetip({ splitTitle: '|', showTitle: false, titleAttribute: 'description', activation: 'click', sticky: true, arrows: true, closePosition: 'title' });
}

Edit:

If the plugin doesn't provide an event, you can hack the plugin to create your own event by finding the ajax function in their code and adding: $('#grid').trigger('gridRefreshEvent'); somewhere.

You can also try asking RadGrid support about the event. Any non-dumb dev would add basic things like this.

Mark
@Mark: problem is that I have not clue what that 'gridRefereshEvent' is on RadGrid. God, do I hate RadGrid based solutions.
epitka
A: 

Why would it get dropped after an ajax call?

If those anchors get overwritten, you must append or create new ones within the ajax success handler?

If so, you can just bind/call those plugins also in the success handler.

Anyways, maybe the load event can help you in any other constelation I can't imagine. load will fire when an element is loaded completly.

Reference: load event

jAndy