実際、レンダリングされたテンプレートで動的コンテンツを追加しているときに問題に直面しています。
ポップオーバー コール:
$(selectorId).popover({
placement: 'bottom',
title: 'New Post',
html: 'true',
content: _template,
container: 'body',
});
レンダリングされた HTML テンプレート
<div>
<label>Name</label><input type="text" name="name" id="name" />
<label>Message</label><input type="text" name="message" id="messgae" />
<label>Select Article</label><select name="article" id="article"></select>
<input type="button" value="submit">
</div>
「記事」に集中するだけです。テンプレートの選択ボックスが空で、レンダリング後に記事データを追加しようとしていますが、機能しません。
データベースから選択ボックスにデータを追加する
$.each(articles,function(){
$("#article").append(this.articleName);
});
記事は JSON 配列です
[
{
'id': 1,
'articleName': 'article1'
},
{
'id': 2,
'articleName': 'article2'
},
{
'id': ,
'articleName': 'article3'
}
]
問題: 選択ボックスに何も表示されません。
目標: ポップオーバーが開かれるたびに、ユーザーは選択ボックスから記事を選択できるようになります。