开发者

jQuery templates, how can I use inputs?

After this conversation I started wondering if it's possible to use that and apply to textboxes. I want something like that:

<script type="jquery/x-jquery-tmpl" id="contactTemplate" >
<d开发者_Go百科iv>
    <input type="text" value= {{ = name }}  />
    <input type="text" value= {{ = phone }}  />
<div>
</script>

<script type="text/javascript">
   var contacts = { name: 'Scott Guthrie', phone: '31415' };

   $(document).ready(function() 
  {
      $('#contactTemplate').tmpl(contacts).appendTo('#contactContainer');
  });
</script>


Sure thing:

<script type="jquery/x-jquery-tmpl" id="contactTemplate" >
    <div>
        <input type="text" value="${name}"  />
        <input type="text" value="${phone}"  />
        <div>
</script>

Here's an example: http://jsfiddle.net/Ca35T/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜