Oh, and Tom, using addEvent on all his images creates a similar problem to
the one he's trying to avoid: processing all the DOM elements on startup. If
he uses addEvent on 3000 elements, he's looking at the same performance
issue as before. By doing in-line onclick assignments, it's probably much,
much faster.
Event delegation won't work, because you'd have to capture the mouseover
event for the parent, which probably contains all 3000 of these but is only
fired when the mouse enters the area the first time.
How would you deal with this?
On Tue, Oct 14, 2008 at 8:50 AM, Aaron Newton <[EMAIL PROTECTED]> wrote:
> One more pointer:
> You've spent a lot of time working this problem out and probably learned
> some things about JavaScript and MooTools in the process. Don't miss out on
> the best thing though: Classes.
>
> Instead of writing a function:
>
> function tipit(image, e) {
> //logic
> }
>
> You should instead create a new class or extend Tips:
>
> var TipIt = new Class({
> //methods, class you want to extend, etc.
> });
>
> I won't espouse all the reasons you should do this, but if you want to know
> more, you can find some additional info here:
>
> http://www.mootorial.com/wiki/mootorial/10-whentowriteclasses
>
> -aaron
>
> On Tue, Oct 14, 2008 at 6:49 AM, tomocchino <
> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
> > wrote:
>
>>
>> event is not a reserved word, it's an object in the global namespace
>> in IE. The error is called by you forgetting to declare your event
>> variable inside the function you're in. You tried to overwrite
>> window.event... that's very, very bad.
>>
>> var event = blah; //works fine, used many, many places in MooTools.
>>
>> let me give you some pointers
>> - Never forget var. It's not optional!
>> - Don't use onwhatever inline events, use addEvent instead which
>> uses the DOM Level 2 standard.
>> - You don't need to extend events anymore in MooTools 1.2, it's done
>> automatically for all events added the proper way (addEvent)
>>
>> $('el').addEvent('mouseover', function(event){
>> event.stop(); //event is already extended
>> });
>>
>>
>> On Oct 14, 2008, at 3:57 AM, DustyReagan wrote:
>>
>> >
>> > Sorry, I got a little trigger happy posting. IE7 doesn't like event =
>> > new Event(e); because event is a reserved word. I just needed to
>> > change the variable name.
>> >
>> > On Oct 13, 9:07 pm, "Iván N Paz" <[EMAIL
>> > PROTECTED]<http://n2.nabble.com/user/SendEmail.jtp?type=node&node=1332583&i=0>>
>> wrote:
>> >> @DustyReagan:
>> >>
>> >> You should really really really avoid this:
>> >>
>> >>> <img onmouseover="tipit(this, event)" ... />
>> >>
>> >> Specifying the javascript like that makes for very obtrusive
>> >> javascript, which we need to avoid above all things!!!!
>> >>
>> >> What about applying the "tipit()" function on domready, instead of
>> >> creating the tooltip (which you will create on your tipit).... Would
>> >> that kill your browser as well????
>> >>
>> >> What about attaching a mouseMove (or the like) event to the "window"
>> >> object and check for the object beneath????
>> >>
>> >> Just throwing some ideas...
>>
>>
>>
>> ------------------------------
>> View message @
>> http://n2.nabble.com/Just-In-Time-Tool-Tips-tp1328767p1332583.html
>> To start a new topic under MooTools Users, email
>> [EMAIL PROTECTED]<[EMAIL PROTECTED]>
>> To unsubscribe from MooTools Users, click here< (link removed) >.
>>
>>
>>
>
-----
The MooTools Tutorial: http://www.mootorial.com www.mootorial.com
CNET Clientside: http://clientside.cnet.com clientside.cnet.com
--
View this message in context:
http://n2.nabble.com/Just-In-Time-Tool-Tips-tp1328767p1333141.html
Sent from the MooTools Users mailing list archive at Nabble.com.