Hi all,
So I know I'm late to the party, but I just discovered Event Delegation
yesterday. Why did everybody keep it from me for so long? (-;
Anyway, I'm trying to make it work with Tips (which has, for some reason,
always caused me grief), and I can't quite figure out how to make it happen.
So within a class, I've got the function I've pasted below. I'm attempting
to attach Tips using mouseover:relay(), but (predictably), the Tip doesn't
display until the *second* time I mouseover the element, because it's
getting attached on the first mouseover. The other thing that seems wrong
with the code below is that it will (I think) attach Tips on *every*
mouseover, not just the first one. There aren't a lot of Tip children of
"this.options.info"--at most just five or so--but the children are updated
via AJAX, so it seems cooler if I could just use delegation to attach it
once and be done with it.
I'm sort of getting the feeling that Tips maybe isn't really designed to
work with Event Delegation, since Tips has a lot of the attaching and
triggering built in, but maybe I just don't know how to use them together.
I'll keep digging, but any advice is appreciated.
Thanks,
Ben
tips: function() {
var that = this;
$(this.options.info).addEvent('mouseover:relay(' + this.options.tipclass +
')', function(event, el){
var tips = new Tips(el, {
text: function(el){
var res = '', id = el.getProperty('data-id');
var container = $('discounts-' + id);
if(container) {
res = container.get('html');
}
return res;
},
className: that.options.tipcontainerclass
});
});
},