Tag Archives: class
Finally: Singletons, the Mootools way
I have been using for a while the “new new Class” syntax to create singletons on the projects I am working on. This is for many reasons, but specially because I didn’t like other solutions like Class.Mutators, Class.Oclude or extending a plain object with $extend(). Now, after discussing a little bit on the Mootools email [...]
Setters & Getters on Mootools classes
Although I haven’t need them for my classes, I thought it would be very cool to have the possibility to use them. Setters and Getters are very popular in modern programming languages, since they let you do some actions when a member/property of an object is being accessed or modified. Setters and Getters are native [...]
Setting up timers and intervals inside JS objects
It may seem trivial but it has its tricky point. Usually, in procedural Javascript (this is, non object oriented programming), timers are set up passing the callback function on a string: function hello() { alert("hello"); } // Will execute hello() after 10 seconds setTimeout('hello()', 10000); For this code to work, hello() has to be [...]
Threads in Javascript
Well, let’s make it clear: There is no way to create actual threads in Javascript. Javascript code runs on a single thread inside the browser. This is, only one line of code is running at a time. In fact, until Google’s Chrome, all pages/tabs opened on a browser where running on the same system thread. [...]
MooTools classes with “Smart Start”
A couple of days ago I was talking with my friend Karsten at work about one small but relevant issue we face when building websites: our beautiful MooTools classes cannot interact with elements on the DOM until the DOM has fully loaded. This, which is obvious, sometimes has some impact. For example, the typical case [...]
Very basic $ function to deal with element classes
When working with plain Javascript (no frameworks involved) some tasks can be harder to deal with than you expected. Here is who to solve one of this issues: dealing with multiple element classes.
