Alan She
unread,Nov 3, 2008, 11:06:32 PM11/3/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to chainjs
I would like to know if I can use chain.js to append select options?
What I want to do is that I have a piece of html as follow,
<select id="categories" name="categories">
<option class="category" value="xxx">XXX</option>
</select>
And I have a list of JSON object like
[
{id:1,name:'aaa'},
{id:2,name:'bbb'},
{id:3,name:'ccc'},
]
I tried to use chain in this way,
$('#categories').items(jsonObject).chain({
'.category' : {
value: '{id}',
text: 'name'
}
});
It doesn't work. The <option> element are copied 3 times but the value
and text are not bound on it.
But the above usage is similar to the way I use for <div> or <span>
elements.
I wish to have a result like this,
<select id="categories" name="categories">
<option class="category" value="1">aaa</option>
<option class="category" value="2">bbb</option>
<option class="category" value="3">ccc</option>
</select>
How can I do this with chain.js?
Thank you very much!