开发者

Jquery overlay form on spring generated page

Fellas!

I'm working on a Java/Spring application to keep track of all approvals granted by some supersuer to the requests generated by final user. For every request the super user will add a comment before confirm it. To do that I'd like to add a overlay div using jquery (something like that http://jqueryui.com/demos/dialog/#modal-form)

In that sample, u开发者_运维知识库ser press the button and the jquery function $( "#create-user" ) will be called. My question is, in my case I've more than a row, have I to generate a single function and form for every rows or is it possible to pass the ID to the funcion?

Another question, how can I pass a parameter (the request_id needed to update the right record on db) to the jquery function?

thanks and sorry for my not so good english!

bye, Andrea


What I'd do is store the specific values you're using or manipulating in the DOM metadata using jQuery.data or something along those lines.

For example, when you spit it out, spit it out in this format:

<table>
  <tr data-myId="1234">
    <td>stuff</td>
   </tr>
</table>

Then the javascript would look something like this:

$("table").find("tr").each(function() {
   $thisElement = $(this);
   thisData = parseInt($thisElement.data("myId"), 10);

   myFunction(thisData);
});


once the user clicks submit:

a javascript function can iterate over all the rows, and see if the user had selected (check mark) them.

If they had been selected, then note the 'id' attribute. Use all these id attributes and create a string: ids="1,2,3,6,10". and assign it to a hidden input form element.

and then submit the form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜