sangram
sangram

Reputation:

Handling Spring MVC form:radiobutton with Jquery

has any one using Spring MVC with Jquery!

i have got a strange problem when handling Spring MVC tags with Jquery.

i used tags of spring MVC to get radiobuttons binded.

<form:form name="Form1" method="post" action="Form1.do" commandName="Page1Command">

<form:radiobutton path="group" value="TTSE" id="DevGroup_TTSE"  />
<form:radiobutton path="group" value="TTDE" id="DevGroup_TTDE"  />

now for some validation task i used Jquery selector as follows:

$("form:radiobutton").click(function() { 
   alert($(this).attr("id"));
 });

now surprisingly i am getting alert with value "Page1Command" the name i have give for commandName.

then i tried with id selector for one perticular radiobutton.

$("#DevGroup_TTDE").click(function(){
     alert($(this).attr("id"));
})

now i am getting the correct value as "DevGroup_TTDE"

what went wrong with this? can't we handle spring MVC tags with Jquery properly.

BTW, i am new to both technologies!

any help?

regards.

Upvotes: 2

Views: 6070

Answers (1)

Jacob Mattison
Jacob Mattison

Reputation: 51062

The form: tags are interpreted on the server side, and generate regular HTML tags on the client side. Since jQuery is only running on the client side, it won't be able to find things using the form: tags. Try running the page and viewing the HTML source, then base your jQuery selectors on what you see there.

Upvotes: 2

Related Questions