• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

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
0
mmoore
Asked:
mmoore
  • 4
  • 2
1 Solution
 
gurpsbassiCommented:
Try using the styleId attribute instead e.g.
<nested:text readonly="true" styleClass="normalText" property="date" size="12" styleId="datepicker" />

Open in new window

0
 
mmooreAuthor Commented:
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!
0
 
mmooreAuthor Commented:
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.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
mmooreAuthor Commented:
It worked!
0
 
gurpsbassiCommented:
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.
0
 
mmooreAuthor Commented:
Great! Thanks for making the extra effort. Regards,
Mike
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now