tags:

views:

19

answers:

1

ok i have this jquery

    $('.make_request').ajaxForm(function() { 
// $('.band_notice').show();
$(this).parents('.accordionContent').find('.band_notice').show();
        }); 

I am using this plugin

I need to find the class element .band_notice that is in the form clicked

here is my html

    <div class="accordionContent">
<form action="/make_requests" class="make_request" method="post"><div style="margin:0;padding:0;display:inline"></div>                                                      .......
            .......
    </tr>
    <tr><td><input id="make_requests" name="commit" type="submit" value="Add to Set" /></td><td><span class="band_notice">Set Added</span></td></tr>
                  </form>


    <div class="accordionContent">
<form action="/make_requests" class="make_request" method="post"><div style="margin:0;padding:0;display:inline"></div>                                                      .......
            .......
    </tr>
    <tr><td><input id="make_requests" name="commit" type="submit" value="Add to Set" /></td><td><span class="band_notice">Set Added</span></td></tr>
                  </form>

For some reason my jquery is a bit off bit this seems like it should be right

$(this).parents('.accordionContent').find('.band_notice').show();
+1  A: 

Just take out the .parents() portion and use the fourth parameter for the form, like this:

$('.make_request').ajaxForm(function(response, status, xhr, form) { 
  form.find('.band_notice').show();
});

From the docs, here are the parameters for your success method:

  1. responseText or responseXML value (depending on the value of the dataType option).
  2. statusText
  3. xhr (or the jQuery-wrapped form element if using jQuery < 1.4)
  4. jQuery-wrapped form element (or undefined if using jQuery < 1.4)
Nick Craver
that actually didnt work...not sure why not...maybe this plugin is altering this
Matt
i did console.log(this) and got Object { url="/make_requests", more...}
Matt
@Matt - Ah, one sec, checking the parameters
Nick Craver
@Matt - I updated the answer on how to do this, since `this` refers to the ajax object itself (and there's no way to provide a `context` option the way you're using it. Using the fourth parameter which is a jQuery object representing the `<form>` is easy enough though.
Nick Craver
awesome thanks...
Matt