Link to home
Start Free TrialLog in
Avatar of mmoore
mmooreFlag for United States of America

asked on

jquery binding to jsp nested:text

I have the following JSP:
<nested:text readonly="true" styleClass="normalText" property="date" size="12" />
and the following JQUERY (this is just something I copied, ultimately all I want is a simple datepicker on a simple text field)
   $( document ).ready(function() {
        $.datepicker.setDefaults(
                $.extend($.datepicker.regional[''])
            );
            $('#datepicker_open').click(function(){
                $('#datepicker').datepicker(
                    'dialog',
                    '28.05.2013',
                    function(){
                        alert('Event onSelect');
                    },
                    { showButtonPanel: true }
                );
            });
    });

I tried to do this:
<nested:text readonly="true" styleClass="normalText" property="date" size="12" id="datepicker" />
but JSP processer rejects the "id" attribute.
Thanks,
Mike
ASKER CERTIFIED SOLUTION
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmoore

ASKER

Well, that works but I don't know why. I'm just learning jquery and I thought #datepicker would only bind to the id attribute. Apparently not. Thanks!
Avatar of mmoore

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for mmoore's comment #a40683392

for the following reason:

Solution worked. Would have been nice to have an explanation of why it works, but I guess I can figure that out on my own.
Avatar of mmoore

ASKER

It worked!
Well, that works but I don't know why. I'm just learning jquery and I thought #datepicker would only bind to the id attribute. Apparently not. Thanks!

It is binding to the Id attribute. If you view the HTML source you will see the text field with the id attribute.

If you look at the API documentation for the text tag in the nested taglib you will see that it extends the <html:text> tag.
The <html:text> tag happens to have a styleId attribute which corresponds to the html id attribute.

I can't seem to find the documentation for the <html:text> tag, this would have shown you the definition of the styleId attribute.
Avatar of mmoore

ASKER

Great! Thanks for making the extra effort. Regards,
Mike