try changing this: within = within ? $('#' + within) : $(document); to this: within = typeof(within) != 'undefined' ? $('#' + within) : $ (document);
On Sep 29, 5:33 pm, Jeremy Darling <jeremy.darl...@gmail.com> wrote: > Sorry, guess it would help if I explained within :). The actual full method > is: > function updateControls(within){ > within = within?$('#'+within):$(document); > within.submit(validateForm); > within.find(".datepicker").datepicker(); > within.find("form").submit(validateForm); > within.find(".datepicker").datepicker(); > within.find('.button').each(function(){ > $(this).addClass('ui-state-default'); > $(this).addClass('ui-corner-all'); > $(this).hover(function(){ > $(this).addClass('ui-state-hover'); > }, function(){ > $(this).removeClass('ui-state-hover'); > }); > }); > within.find("textarea.richtext").each(function(i, o){ > CKEDITOR.replace(o.id, {uiColor: '#6F0002'}); > $(o).before("<a href=\"#\" onclick=\"toggleEditor('"+o.id+"'); return > false;\">Toggle Editor</a><br />"); > }); > within.find('.treetable').treeTable(); > > } > > So, basically I can pass a dynamic tab into the method or just let it parse > the entire document. In this case its parsing the entire document. > > On Tue, Sep 29, 2009 at 11:29 AM, Nalum <mallon.l...@gmail.com> wrote: > > > Try changing within to $('form'). > > > I haven't come across within so I don't know anything about it. > > > On Sep 29, 4:45 pm, Jeremy <jeremy.darl...@gmail.com> wrote: > > > I have built out a fairly rhobust app using jquery and jquery-ui all > > > was going well until we started to bring different screens together > > > inside a tabbed interface. Seems that now when we execute our > > > validation code on one form its checking the fields of all other forms > > > on the page. > > > > All of my forms do have unique ID's and all elements within all forms > > > have unique ID's. > > > > My understanding of using this.find inside of the submit event was > > > that it should only find the forms elements am I wrong? > > > > Method that performs the actual validation: > > > function validateForm(event){ > > > var allOk = true; > > > $(this).find("*[validation]").each(function(){ > > > var elem = $(this); > > > var val = elem.attr('validation'); > > > var fn = elem.attr('id'); > > > var ok = true; > > > if(val!='') eval('ok = '+val+';'); > > > ok = (ok)?true:false; > > > if(allOk&&(!ok)) elem.focus(); > > > if(ok) elem.removeClass('error'); > > > else{ > > > elem.change(function(){ > > > var elem = $(this); > > > var fn = elem.attr('id'); > > > var val = elem.attr('validation'); > > > var ok = true; > > > if(val!='') eval('ok = '+val+';'); > > > if(ok) elem.removeClass('error'); > > > }); > > > elem.addClass('error'); > > > } > > > allOk = allOk && ok; > > > }); > > > this.valid = allOk; > > > if(!allOk) if(event) event.preventDefault(); > > > return allOk; > > > > } > > > > Initialized with (inside document.ready): > > > within.find("form").submit(validateForm); > > > > Thanks, > > > - Jeremy