[jQuery] Re: jQuery Form Plugin target confusion

2008-05-29 Thread Aree

Hey Lasthaai,

I suffered the same issue and realised what was going on. Given that $
(this) is bound back to this function in which it currently resides,
affectively causes an infinite loop. Here is a way around this issue,
while still using the jquery forum plugin:

$(function() {
for (var i = $('.form').length - 1; i >= 0; i--){
$('.form:eq('+i+')').ajaxForm({
target: '.form:eq('+i+') > .recommend'
beforeSubmit: function(data, set, options) {
alert( $(set).attr( 'action' ) );
}
});
};
});

Hope this works for you :)

Aree

On Apr 9, 3:36 am, Iasthaai <[EMAIL PROTECTED]> wrote:
> I'm using the jQuery form plugin and specifying my target as so:
>
> $(function() {
> var _options = {
> target: $( this ),
> beforeSubmit: function(data, set, options) {
>   alert( $(set).attr( 'action' ) );
> }
> }
> $( '.form' ).ajaxForm( _options );
>
> });
>
> I've also tried using just the 'this' keyword. Anyway, when I use this
> it freezes the browser... My goal is to make the response target
> wrapper the same form that I'm submitting (basically a refresh of the
> newly updated form). I can't just leave the form as is due to some
> extra bits of JS that aren't form elements that will be reset when the
> response is loaded.
>
> Am I specifying my target incorrectly for what I want to achieve?
>
> PS: I've changed my target to the specificy form using an id and also
> I set the target to $( '.form' ) which posts the response in ALL of my
> forms, so I know that it is working, just not with the 'this' keyword
> for some reason.


[jQuery] Re: jQuery Form Plugin target confusion

2008-04-08 Thread Mike Alsup

>  Thanks Mike that did the trick. I want to ask a noob question about
>  the significance of the $ in front of the form variable that you
>  suggest. What is the difference besides using just form or set as that
>  variable name without a $ preceding it?

No difference.  It just helps me remember that the var is a jQuery
object and not a DOM object.


[jQuery] Re: jQuery Form Plugin target confusion

2008-04-08 Thread Iasthaai

Thanks Mike that did the trick. I want to ask a noob question about
the significance of the $ in front of the form variable that you
suggest. What is the difference besides using just form or set as that
variable name without a $ preceding it?

On Apr 8, 10:55 am, "Mike Alsup" <[EMAIL PROTECTED]> wrote:
> >  $(function() {
> > var _options = {
> > target: $( this ),
> > beforeSubmit: function(data, set, options) {
> >   alert( $(set).attr( 'action' ) );
> > }
> > }
> > $( '.form' ).ajaxForm( _options );
> >  });
>
> >  I've also tried using just the 'this' keyword. Anyway, when I use this
> >  it freezes the browser... My goal is to make the response target
> >  wrapper the same form that I'm submitting (basically a refresh of the
> >  newly updated form). I can't just leave the form as is due to some
> >  extra bits of JS that aren't form elements that will be reset when the
> >  response is loaded.
>
> >  Am I specifying my target incorrectly for what I want to achieve?
>
> >  PS: I've changed my target to the specificy form using an id and also
> >  I set the target to $( '.form' ) which posts the response in ALL of my
> >  forms, so I know that it is working, just not with the 'this' keyword
> >  for some reason.
>
> 'this' does not equal the form where you are using it.  Most likely
> 'this' is the document at that point.   Try this instead:
>
> $(function() {
>var _options = {
>beforeSubmit: function(data, $form, options) {
>  options.target = $form;
>}
>};
>$( '.form' ).ajaxForm( _options );
>
> });


[jQuery] Re: jQuery Form Plugin target confusion

2008-04-08 Thread Mike Alsup

>  $(function() {
> var _options = {
> target: $( this ),
> beforeSubmit: function(data, set, options) {
>   alert( $(set).attr( 'action' ) );
> }
> }
> $( '.form' ).ajaxForm( _options );
>  });
>
>
>  I've also tried using just the 'this' keyword. Anyway, when I use this
>  it freezes the browser... My goal is to make the response target
>  wrapper the same form that I'm submitting (basically a refresh of the
>  newly updated form). I can't just leave the form as is due to some
>  extra bits of JS that aren't form elements that will be reset when the
>  response is loaded.
>
>  Am I specifying my target incorrectly for what I want to achieve?
>
>  PS: I've changed my target to the specificy form using an id and also
>  I set the target to $( '.form' ) which posts the response in ALL of my
>  forms, so I know that it is working, just not with the 'this' keyword
>  for some reason.


'this' does not equal the form where you are using it.  Most likely
'this' is the document at that point.   Try this instead:

$(function() {
   var _options = {
   beforeSubmit: function(data, $form, options) {
 options.target = $form;
   }
   };
   $( '.form' ).ajaxForm( _options );
});