現在、タグid
内の値を使用しています to 、つまり:div
serialize
HTML:
<div class="column">
<div id="portlet_1">some content here</div>
<div id="portlet_2">some content here</div>
<div id="portlet_3">some content here</div>
</div>
jQuery:
$(this).sortable('serialize', {key: 'item'})
それはうまくいきます。
問題は、必要に応じて同じポートレットを何度も画面に表示できるように、ユーザーが画面に表示するポートレットを動的に選択できるようにする必要があることです。つまり、次のようになります。
HTML:
<div class="column">
<div id="portlet_1">some content here</div>
<div id="portlet_1">some content here</div>
<div id="portlet_1">some content here</div>
<div id="portlet_2">some content here</div>
<div id="portlet_2">some content here</div>
<div id="portlet_3">some content here</div>
</div>
これは、同一id
の s のために多くの問題を引き起こします。
s のclass
代わりに esを使用するように構造を変更したので、次のようになります。id
HTML:
<div class="column">
<div class="portlet_1">some content here</div>
<div class="portlet_1">some content here</div>
<div class="portlet_1">some content here</div>
<div class="portlet_2">some content here</div>
<div class="portlet_2">some content here</div>
<div class="portlet_3">some content here</div>
</div>
class
の代わりに に基づいてシリアル化するにはどうすればよいid
ですか?
id
以下は、 sに基づいてシリアル化されるために機能しないコードのより完全な抜粋です。
jQuery:
$(".column").sortable({
connectWith: '.column',
update: function(event, ui) {
var that = this;
$.ajax({
url: 'some web service here',
type: 'POST',
data: { strItems:$(that).sortable('serialize', {key: 'item'}) },
error: function(xhr, status, error) {
//some error message here
},
success: function() {
//do something on success
}
});
}
});
申し訳ありませんが、私は古い jquery バージョン 1.4 を使用していることを忘れていました。