Question

I'm currently working on the Tips.js from mootools library and my code breaks on the line that has those el.$tmp, and console says it's undefined

Can anybody help me?

Was it helpful?

Solution

in 1.11 (haven't checked in 1.2+) $tmp is a reference to the element itself, created and used internally by the garbage collector:

var Garbage = {

    elements: [],

    collect: function(el){
        if (!el.$tmp){
            Garbage.elements.push(el);
            el.$tmp = {'opacity': 1};
        }
        return el;
    },

    trash: function(elements){
        for (var i = 0, j = elements.length, el; i < j; i++){
            if (!(el = elements[i]) || !el.$tmp) continue;
            if (el.$events) el.fireEvent('trash').removeEvents();
            for (var p in el.$tmp) el.$tmp[p] = null;
            for (var d in Element.prototype) el[d] = null;
            Garbage.elements[Garbage.elements.indexOf(el)] = null;
            el.htmlElement = el.$tmp = el = null;
        }
        Garbage.elements.remove(null);
    },

    empty: function(){
        Garbage.collect(window);
        Garbage.collect(document);
        Garbage.trash(Garbage.elements);
    }

};

the lines el.$tmp = {'opacity': 1}; (in collect method above) and el.htmlElement = el.$tmp = el = null; (in trash method above) are the only places in the source where this property is assigned that i could find, although it's called by various other methods, such as Element.setOpacity and Element.getStyle (specifically, only to return opacity value), as well as methods in the Tips class

1.2 might not have this issue, but in any case, hope that helps and sorry i couldn't help more

OTHER TIPS

I'd suggest taking your question and posting it, along with a link to the page to either/or/and:

http://mooforum.net

http://groups.google.com/group/mootools-users/topics

That's the community that swarms with it.

Now as for answering it here - I'd need a lot more information (code example?)

Hmmm. I'm not exactly sure what el.$tmp is a reference to in MooTools but a message stating "console is undefined" is probably because someone was trying to log to the Firebug (or another) console and that object does not exist if you don't have Firebug and friends.

If you don't have http://getfirebug.com'>Firebug installed for Firefox then you might give it a shot. See if you can find the console statement and remove it. Also, if you aren't using Firefox, you can use Firebug Lite in IE, Safari, or Opera.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top