views:

52

answers:

1

Hi stack folk!

I'm working with jQuery.validate. One of its options is "success" where a function can be called upon valid user entry on a form. The only argument that can be passed is "label" which (as I understand) is a dynamically added label field to the right of the input element.

I need to perform a series of actions on a sibling "div" but I'm having enormous trouble trying to traverse to the div I want. I can't even find where the label is. Are there tricks to finding it?

I've used things such as alert (label.parents('.formrow').html()); and alert (label.parent().parent().parent().html()); and they all return "null" ... alert (label.html()); returns ""

Similar methods have worked for me in the past. Once I find something I then employ next() or find() and all is well. Is there another way?

PS. Example code:

success: function(label) {
  errorspotholder = label.parents('.formrow').find('.rederrorx');
  errorspotholder.removeClass('rederrorx').addClass('norederrorx').qtip('destroy');
            },
+1  A: 

This question is a bit case-specific and therefore probably not very useful to anyone else...

but what I did instead of using "label" was to declare a global variable based on another dynamic selector from jQuery.validate (in this case I used "element" from jQuery.validate's "errorPlacement").

It worked.

Marko also suggested in the comments finding lost elements by looking at the generated code from Firebug (getfirebug.com) console. Great idea! I didn't find my lost label but it should have worked and would probably work for someone else.

Emile