4 ms·
Thanks for the post. I know the introduction is a bit long, sorry. I wrote it while I was hacking and I think I was even drinking some wine during that process
by rodp 17y ago
Thanks for the post.
I know the introduction is a bit long, sorry. I wrote it while I was hacking and I think I was even drinking some wine during that process, so... I'll write a shorter, clearer introduction soon, I promise.
The problems that occur when your JavaScript (jQuery) code starts piling up are nothing new. I've been finding ways to organize my code for ages.
The idea behind behaviors is simple really:
1. Encapsulate some type of functionality within a good old function.
2. "Attach" this function to some elements as their "behavior".
3. Methods and properties of all behaviors can be accessed from anywhere, which allows interaction.
It's a simple object-oriented philosophy and it's nothing new. I just think it would be nice to have a standard way of organizing huge piles of JavaScript without having to use some huge JS framework or moving too far away from the jQuery coding style.