开发者

jQuery - live method with jquery tmpl

I'm appending rows to a table using the jQuery tmpl plugin. Each row corresponds to three input fields, and a 'save' link. Save links I'm detecting using:

$(".saveClick").live('click',function(){
// 1. get 3 values for the row in question (stuck here)
// 2. process values via ajax (no problems here)
// 3. create new row from template (no problems here)

});

I can do the AJAX stuff to process the values, I just don't know what's the best way to access the values?

Any advice would be swell.

Thanks

Edit:

for clarification HTML:

<table id=inputTable>
<tr>
<td>cola</td>
<td>colb</td>
<td>colc</td>
<td>&nbsp;</td>
</tr>
</table>

jQuery Template:

<script id="tmplAddRow" type="text/x-jquery-tmpl">
<tr>
<td><input id="inA"></td>
<td><input id="inB"></td>
<td><input id="inC">开发者_JAVA技巧;</td>
</tr>
</script>


So it seems that your question is really: "How can I access table cell values?"

That was asked before, so you can find the answer at How to get a table cell value using jQuery?.


if you use a table you can "return" up until relative at the row of your save link and after you can find the fields

$(".saveClick").parent().find("selector-of-field");


example:

$(".saveClick").live('click',function(){


alert($(this).closes("tr").find("td:nth-child(1) input").val());


}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜