jQuery like click syntax, just curious

a place to get help

Moderator: 1.2 Moderators

Forum rules
  • Every time you need help create a new thread (but please use the search function before, as your problem maybe has already been solved)
  • use code highlighting (help)
  • After your problem has been solved you have to rename the subject to "[solved] <Topicname>" AND set the Topic icon as solved (the green check)

jQuery like click syntax, just curious

Postby ghazal on Thu Nov 27, 2008 1:43 pm

Hi,
I'v been using happily David Walsh jQuery-like click syntax and "extended" it naturally to mouseleave mousenter :
http://davidwalsh.name/implement-jquery-click-syntax-mootools#comments
  1.             Element.implement({
  2.         'click': function(fn) {
  3.             return this.addEvent('click',fn);
  4.         }
  5.     });
  6.     Element.implement({
  7.         'mouseenter': function(fn) {
  8.             return this.addEvent('mouseenter',fn);
  9.         }
  10.     });
  11.     Element.implement({
  12.         'mouseleave': function(fn) {
  13.             return this.addEvent('mouseleave',fn);
  14.         }
  15.     });


1st question, is it possible to make it only one function ? Like this it is a bit "gross".
Also,looks like it could be :
  1. Element.implement({
  2.         'click': function(fn) {
  3.              this.addEvent('click',fn);
  4.         }
  5.     });


What do you think ?
ghazal
mootools fan
 
Posts: 79
Joined: Sun Aug 10, 2008 3:28 pm

Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest