Mike,

The DOM elements didn't exist before I created this array. That makes
perfect sense now. I added the ObjectMap to the $(document).ready()
calloback and problem solved.

I appreciate your help. My apologies. I will remember to post such
questions to the main jQuery mailings.


Thank you again.

- John

On Dec 24, 1:47 am, "Michael Geary" <[email protected]> wrote:
> At the time you create your ObjectMap, do the DOM elements you're trying to
> reference already exist?
>
> If your ObjectMap definition is earlier in the HTML output than the DOM
> elements themselves, then they won't exist yet. In your test code, if you
> look at o.length, I'll bet it's zero - which means that the selector did not
> find any matching elements.
>
> You need to make sure the DOM elements exist before you try to use them in
> selectors, either by putting the ObjectMap creation code after those
> elements, or by putting it inside a $(document).ready() callback.
>
> BTW, for future reference, a question like this should go in the main jQuery
> mailing list. The jquery-dev list is for discussions related to the
> development of the jQuery library itself, not questions about the use of
> jQuery.
>
> -Mike
>
>
>
> > From: Monty
>
> > Hello All,
>
> > I'm trying to create a jQuery map/array of all controls on an
> > ASP.net page for easier client runtime access. I output the
> > following to the
> > page:
>
> > var ObjectMap = {
> >                    ctl00: $("#ctl00_DefaultContent_ctl00"),
> >                    chkEmployee:
> > $("#ctl00_DefaultContent_chkEmployee"),
> >                    ctl01: $("#ctl00_DefaultContent_ctl01"),
> >                    chkContractor:
> > $("#ctl00_DefaultContent_chkContractor"),
> >                    ctl02: $("#ctl00_DefaultContent_ctl02"),
> >                    chkVisitor:
> > $("#ctl00_DefaultContent_chkVisitor"),
> >                    ctl03: $("#ctl00_DefaultContent_ctl03")
> >            };
>
> > which refers to ASP.Net named controls. However, when I
> > access this array with the following it does not work (see
> > variable o):
>
> > function TogglePersonType()
> > {
> >     var o = ObjectMap.chkEmployee;
> >     alert(o.html());
> >     o.hide();
> >     //e.toggle();
> >     //alert(e.html());
> >     //alert(e.toHTML());
> > }
>
> > o.html() returns null and other jQuery methods do not seem to
> > work (e.g. hide()). No error is thrown though.
>
> > Any pointers would be greatly appreaciated.
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to