[jQuery] Re: problems with the starterkit

2007-04-07 Thread Mike Alsup



jQuery does a bit more:


All I'm saying is that you can't call a method that doesn't exist.  I
don't care how clever the event system is.  ;-)

Mike


[jQuery] Re: problems with the starterkit

2007-04-07 Thread Klaus Hartl


Jörn Zaefferer schrieb:


Mike Alsup schrieb:


> Huh?  The reset event is not bound by jQuery.  Are you thinking of 
submit?

>

No, starting with jQuery 1.1 element events are also triggered. The
following for example will focus the first input in the page:


Yes, but those events have to be bound.  The reset event is not bound 
by jQuery.

jQuery does a bit more:

trigger: function(type, data, element) {
// Clone the incoming data, if any
data = jQuery.makeArray(data || []);

// Handle a global trigger
if ( !element )
jQuery.each( this.global[type] || [], function(){
jQuery.event.trigger( type, data, this );
});

// Handle triggering a single element
else {
var handler = element["on" + type ], val,
fn = jQuery.isFunction( element[ type ] );

if ( handler ) {
// Pass along a fake event
data.unshift( this.fix({ type: type, target: element }) );

// Trigger the event
if ( (val = handler.apply( element, data )) !== false )
this.triggered = true;
}

if ( fn && val !== false )
element[ type ]();

this.triggered = false;
}
},

The element[ type ](); part is particular intersting.



So the element inherent method is triggered, no matter if there is an 
additional event bound or not?



-- Klaus


[jQuery] Re: problems with the starterkit

2007-04-07 Thread Jörn Zaefferer


Mike Alsup schrieb:


> Huh?  The reset event is not bound by jQuery.  Are you thinking of 
submit?

>

No, starting with jQuery 1.1 element events are also triggered. The
following for example will focus the first input in the page:


Yes, but those events have to be bound.  The reset event is not bound 
by jQuery.

jQuery does a bit more:

trigger: function(type, data, element) {
// Clone the incoming data, if any
data = jQuery.makeArray(data || []);

// Handle a global trigger
if ( !element )
jQuery.each( this.global[type] || [], function(){
jQuery.event.trigger( type, data, this );
});

// Handle triggering a single element
else {
var handler = element["on" + type ], val,
fn = jQuery.isFunction( element[ type ] );

if ( handler ) {
// Pass along a fake event
data.unshift( this.fix({ type: type, target: element }) 
);

// Trigger the event
if ( (val = handler.apply( element, data )) !== false )
this.triggered = true;
}

if ( fn && val !== false )
element[ type ]();

this.triggered = false;
}
},

The element[ type ](); part is particular intersting.

--
Jörn Zaefferer

http://bassistance.de



[jQuery] Re: problems with the starterkit

2007-04-07 Thread Mike Alsup



> Huh?  The reset event is not bound by jQuery.  Are you thinking of submit?
>

No, starting with jQuery 1.1 element events are also triggered. The
following for example will focus the first input in the page:


Yes, but those events have to be bound.  The reset event is not bound by jQuery.

Mike


[jQuery] Re: problems with the starterkit

2007-04-06 Thread Klaus Hartl


Mike Alsup schrieb:



$("#form").reset() should work if it is a correct form. (We attempt to
trigger the default event wherever possible.)


Huh?  The reset event is not bound by jQuery.  Are you thinking of submit?



No, starting with jQuery 1.1 element events are also triggered. The 
following for example will focus the first input in the page:


$('input:eq(0)').focus();

This is especially cool because you don't have to worry about if the 
element exists.


Before jQuery 1.1 you would have to do:

var inputs = $('input');
if (inputs[0]) {
inputs[0].focus();
}


-- Klaus


[jQuery] Re: problems with the starterkit

2007-04-06 Thread Jörn Zaefferer


John Resig schrieb:


$("#form").reset() should work if it is a correct form. (We attempt to
trigger the default event wherever possible.)

O wow, I just opened up the starterfile zip - it uses a
version of jQuery that's pre-dates jQuery 1.0! Yikes. No wonder the
code was acting strange for you.
Ooops, fixed! I've update both the startkit and the tutorial to reflect 
the change: The starterkit doesn't include jQuery itself nor plugins, so 
there is no risk of providing a slightly outdated version.


Let me know if anything doesn't work as expected.

--
Jörn Zaefferer

http://bassistance.de



[jQuery] Re: problems with the starterkit

2007-04-06 Thread spinnach


you mean $("#form")[0].reset() ?

Mike Alsup wrote:



$("#form").reset() should work if it is a correct form. (We attempt to
trigger the default event wherever possible.)


Huh?  The reset event is not bound by jQuery.  Are you thinking of submit?





[jQuery] Re: problems with the starterkit

2007-04-06 Thread Mike Alsup



$("#form").reset() should work if it is a correct form. (We attempt to
trigger the default event wherever possible.)


Huh?  The reset event is not bound by jQuery.  Are you thinking of submit?


[jQuery] Re: problems with the starterkit

2007-04-05 Thread John Resig


$("#form").reset() should work if it is a correct form. (We attempt to
trigger the default event wherever possible.)

O wow, I just opened up the starterfile zip - it uses a
version of jQuery that's pre-dates jQuery 1.0! Yikes. No wonder the
code was acting strange for you.

JJ - Try using a copy of jQuery from here:
http://jquery.com/src/jquery-latest.js

--John

On 4/5/07, Mike Alsup <[EMAIL PROTECTED]> wrote:


That looks like an error in the tutorial.  It should be:

$("#form")[0].reset();

> I got stuck in the following section, couldn't make it work:
>
>  $(document).ready(function() {
>// use this to reset a single form
>$("#reset").click(function() {
>  $("#form").reset();
>});
>  });
>
> I modified the values of the form's fields and when I clicked on the
> Reset link, nothing happened, I tried it in Firefox (Linux and
> windows) and ie 7.
>
> I updated to the latest jquery.js and this time firebug says there is
> an error:
>
> $("#form").reset is not a function
>
> So, am I doing something wrong or should I ignore that section of the
> tutorial?



[jQuery] Re: problems with the starterkit

2007-04-05 Thread Mike Alsup


That looks like an error in the tutorial.  It should be:

$("#form")[0].reset();


I got stuck in the following section, couldn't make it work:

 $(document).ready(function() {
   // use this to reset a single form
   $("#reset").click(function() {
 $("#form").reset();
   });
 });

I modified the values of the form's fields and when I clicked on the
Reset link, nothing happened, I tried it in Firefox (Linux and
windows) and ie 7.

I updated to the latest jquery.js and this time firebug says there is
an error:

$("#form").reset is not a function

So, am I doing something wrong or should I ignore that section of the
tutorial?