knockout.js - Knockoutjs native template - To create url -


how create url using knockout js native templating.

<a href="http://" title="visit site">     <span data-bind="text: site"></span> </a> 

say expression

<span data-bind="text: site"> 

substitute www.xyz.com. looking way prefix http://.

so,

<a href="http://${site}" title="visit site"> 

which may work jquery templating. in essence, wonder need <span>, <li> etc output text.

by using data-bind attr binding. can use plain javascript in data-bind, can use default concatenation

<a data-bind="attr: {'href':  'http://' + $data.site}, text: 'visit site'"></a> 

data-bind can done on practically everything, long rendered dom. can put on <a> tags, or whatever want use


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -