[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread James

Yes, basically two different way to do the same thing.
Though with bind(), you can define more than one type of events at
once to the same callback.

.bind('mouseover mouseout blur', function(){...

On Apr 6, 6:53 am, jQueryAddict jqueryadd...@gmail.com wrote:
 I want to do something based on the click event.  I was looking at
 examples and at the jQuery Docs.  Read them but so then a .blind() is
 adding an event handler where .click() is obviously an event handler
 but you could I guess use either or to handle for example a click
 event:

 .bind('click', function(){...

 or

 .click(function(){

 right? either will work on whatever element you're working with
 right?  just 2 different ways of doing the same thing in jQuery I
 assume.


[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread Nikola

Is there any performance difference at all?  Say between using .hover
vs. binding to mouseenter and mouseleave?

On Apr 6, 6:40 pm, James james.gp@gmail.com wrote:
 Yes, basically two different way to do the same thing.
 Though with bind(), you can define more than one type of events at
 once to the same callback.

 .bind('mouseover mouseout blur', function(){...

 On Apr 6, 6:53 am, jQueryAddict jqueryadd...@gmail.com wrote:



  I want to do something based on the click event.  I was looking at
  examples and at the jQuery Docs.  Read them but so then a .blind() is
  adding an event handler where .click() is obviously an event handler
  but you could I guess use either or to handle for example a click
  event:

  .bind('click', function(){...

  or

  .click(function(){

  right? either will work on whatever element you're working with
  right?  just 2 different ways of doing the same thing in jQuery I
  assume.- Hide quoted text -

 - Show quoted text -


[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread James

Not really. hover is theoretically just a very tad bit slower because
internally, hover is calling mouseenter and mouseleave:

 hover: function(fnOver, fnOut) {
  return this.mouseenter(fnOver).mouseleave(fnOut);
 }

On Apr 6, 1:56 pm, Nikola nik.cod...@gmail.com wrote:
 Is there any performance difference at all?  Say between using .hover
 vs. binding to mouseenter and mouseleave?

 On Apr 6, 6:40 pm, James james.gp@gmail.com wrote:

  Yes, basically two different way to do the same thing.
  Though with bind(), you can define more than one type of events at
  once to the same callback.

  .bind('mouseover mouseout blur', function(){...

  On Apr 6, 6:53 am, jQueryAddict jqueryadd...@gmail.com wrote:

   I want to do something based on the click event.  I was looking at
   examples and at the jQuery Docs.  Read them but so then a .blind() is
   adding an event handler where .click() is obviously an event handler
   but you could I guess use either or to handle for example a click
   event:

   .bind('click', function(){...

   or

   .click(function(){

   right? either will work on whatever element you're working with
   right?  just 2 different ways of doing the same thing in jQuery I
   assume.- Hide quoted text -

  - Show quoted text -




[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread Erik Beeson
But slower by 1 function call 1 time. I'd call that negligible unless you're
developing for a pocket watch.

--Erik


On Mon, Apr 6, 2009 at 5:08 PM, James james.gp@gmail.com wrote:


 Not really. hover is theoretically just a very tad bit slower because
 internally, hover is calling mouseenter and mouseleave:

 hover: function(fnOver, fnOut) {
  return this.mouseenter(fnOver).mouseleave(fnOut);
  }

 On Apr 6, 1:56 pm, Nikola nik.cod...@gmail.com wrote:
  Is there any performance difference at all?  Say between using .hover
  vs. binding to mouseenter and mouseleave?
 
  On Apr 6, 6:40 pm, James james.gp@gmail.com wrote:
 
   Yes, basically two different way to do the same thing.
   Though with bind(), you can define more than one type of events at
   once to the same callback.
 
   .bind('mouseover mouseout blur', function(){...
 
   On Apr 6, 6:53 am, jQueryAddict jqueryadd...@gmail.com wrote:
 
I want to do something based on the click event.  I was looking at
examples and at the jQuery Docs.  Read them but so then a .blind() is
adding an event handler where .click() is obviously an event handler
but you could I guess use either or to handle for example a click
event:
 
.bind('click', function(){...
 
or
 
.click(function(){
 
right? either will work on whatever element you're working with
right?  just 2 different ways of doing the same thing in jQuery I
assume.- Hide quoted text -
 
   - Show quoted text -
 
 



[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread Josh Powell

.bind enables you to pass variables into the callback function via the
e.data attribute in the event.

$(document).bind('click', {'foo': 'bar'}, function(e) {
   console.log(e.data.foo);
});

Can't do that with the .click shortcut.

Josh Powell

On Apr 6, 9:53 am, jQueryAddict jqueryadd...@gmail.com wrote:
 I want to do something based on the click event.  I was looking at
 examples and at the jQuery Docs.  Read them but so then a .blind() is
 adding an event handler where .click() is obviously an event handler
 but you could I guess use either or to handle for example a click
 event:

 .bind('click', function(){...

 or

 .click(function(){

 right? either will work on whatever element you're working with
 right?  just 2 different ways of doing the same thing in jQuery I
 assume.