Select within context behavior

14 views
Skip to first unread message

Don Harden

unread,
Sep 30, 2011, 4:42:05 PM9/30/11
to jQuery Editable Combobox Support

First of all let me say many thanks and much high praise for jQuery
Editable Combobox and it creator, Lukasz Rajchel.

To save some parsing by jQuery I wanted to select by class context
with in a larger div.

These worked as expected:
$('#DBaccess').jec({ ... })
$('select').jec({ ... })
$('select', $('#DBaccess')).jec({ ... })
$('.JEC').jec({ ... })

But these did not work.
$('#DBaccess', $('.JEC')).jec({ ... })
$('select', $('.JEC')).jec({ ... })

So I guess either I'm doing something wrong or I can't select by class
context with in my DBaccess div and I also can not parse only <select>
tags for the JEC class.

Any suggestions?

Thanks,
Don


Thane

unread,
Oct 6, 2011, 7:23:46 AM10/6/11
to jQuery Editable Combobox Support
I've just tried something similar and it worked fine.

Are you sure your selectors are correct?

Perhaps $('#DBaccess', $('.JEC')) or $('select', $('.JEC')) doesn't
match any valid select element?

Try executing your selectors in console and check if they are correct.

Don Harden

unread,
Oct 7, 2011, 10:42:26 AM10/7/11
to jquer...@googlegroups.com

You're right Thane.  These selectors don't select anything.

    $('#DBaccess', $('.JEC'))
    $('select', $('.JEC'))

I just don't understand why not.   The   <div id="DBaccess"> contains a form with <select class="JEC" ...
So I thought the above two selectors would work.

Got my script working with $('select', $('#Form_ID')

Don




--
You received this message because you are subscribed to the Google Groups "jQuery Editable Combobox Support" group.
To post to this group, send email to jquer...@googlegroups.com.
To unsubscribe from this group, send email to jquery-jec+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jquery-jec?hl=en.


Thane

unread,
Oct 7, 2011, 3:17:36 PM10/7/11
to jQuery Editable Combobox Support
They don't work because the second argument ($('.JEC') in your case)
should be more generic then the first one. This construct allow you to
speed up selectors because they don't have to work on entire DOM tree
and they can limit their searches to a part of it.

So this should work for you $('.JEC', $('#DBacess'));

Don Harden

unread,
Oct 10, 2011, 11:09:30 AM10/10/11
to jquer...@googlegroups.com

Thanks for the explanation.  Seems I had my selection logic backwards.

Don 
Reply all
Reply to author
Forward
0 new messages