わかりました、これに対する答えを見たら、私はばかげていると感じます。私はそれを確信しています。
これは以前とまったく同じ方法で作成しましたが、現在、新しいバージョン用にコードをリファクタリングしています。jQuery Mobile で折りたたみ可能なセットを動的に作成しようとしていますが、html が正しく表示されません。
<div data-role="header">
<h2>Playground</h2>
</div>
<div data-role="content">
<div data-role="button" id="addprimary" data-inline="true">Add 5</div>
<div data-role="collapsible">
<h4>Collapsible</h4>
<form id="makecollapsible">
</form>
</div>
</div>
<div data-role="footer">
<h4>Please, no applause</h4>
</div>
</div>
<script>
$('#addprimary').on('click', function () {
Markup.Collapsible();
});
var Markup = new Object();
Markup.Collapsible = function () {
$('#makecollapsible')
.append($('<div>')
.attr({ 'data-role': 'collapsible-set', 'id': 'primary' })
);
for (i = 0; i < 5; i++) {
($('<div>')
.attr({ 'data-role': 'collapsible', 'data-content-theme': 'c',
'data-collapsed': 'true' })
.html('<h4>' + i +'</h4>'))
.appendTo('#primary');
}
}
</script>
誰かがこのhttp://jsfiddle.net/c2jLY/を見て、私が間違っていることを教えてください。私<div>
のdata-role='collapsible'
は折りたたみ可能なものとしてレンダリングされません。これは、後で入れようとしている HTML にも影響を与えています。
助けていただければ幸いです、ありがとう!