上.prev経由でコンテンツを選択し、変更することはできません。次に、最も近い要素が.fields
であることを隠し、関数get_new_position_for_all_items()
を呼び出します。は、私は次のjQueryを持ってjQueryの
私が抱えている問題は、.sortable_shop_item_position
のクラスを別のものに変更できないため、削除されたget_new_position_for_all_items()
フィールドが新しい位置のソートに含まれないようにするためです。
.sortable_shop_item_position
の値を変更するなどの単純な操作を試みましたが、jQueryを識別して選択することができないようです。
.sortable_shop_item_position
には、li
で囲まれたものがいくつかあります。
お知らせください。どうもありがとう。
<li class="fields sortable_shop_item">
<p style="background-color: yellow; margin: 10px">
<span class="handle">[drag]</span>
<br>
<input id="country_shops_attributes_1_country_date" type="text" value="2012-02-02" size="30" name="country[shops_attributes][1][country_date]">
<label for="country_shops_attributes_1_country_date">country Date</label>
<br>
<input id="country_shops_attributes_1_position" class="sortable_shop_item_position" type="text" value="3" size="30" name="country[shops_attributes][1][position]">
<label for="country_shops_attributes_1_position">Position</label>
<br>
<input id="country_shops_attributes_1__destroy" class="destroy_field" type="hidden" value="false" name="country[shops_attributes][1][_destroy]">
<a onclick="remove_fields(this); return false;" href="#">remove</a>
</p>
<li class="fields sortable_shop_item">
<p style="background-color: yellow; margin: 10px">
<span class="handle">[drag]</span>
<br>
<input id="country_shops_attributes_2_country_date" type="text" value="2012-02-02" size="30" name="country[shops_attributes][2][country_date]">
<label for="country_shops_attributes_2_country_date">country Date</label>
<br>
<input id="country_shops_attributes_2_position" class="sortable_shop_item_position" type="text" value="3" size="30" name="country[shops_attributes][2][position]">
<label for="country_shops_attributes_2_position">Position</label>
<br>
<input id="country_shops_attributes_2__destroy" class="destroy_field" type="hidden" value="false" name="country[shops_attributes][2][_destroy]">
<a onclick="remove_fields(this); return false;" href="#">remove</a>
</p>
<li class="fields sortable_shop_item">
<p style="background-color: yellow; margin: 10px">
<span class="handle">[drag]</span>
<br>
<input id="country_shops_attributes_3_country_date" type="text" value="2012-02-02" size="30" name="country[shops_attributes][3][country_date]">
<label for="country_shops_attributes_3_country_date">country Date</label>
<br>
<input id="country_shops_attributes_3_position" class="sortable_shop_item_position" type="text" value="3" size="30" name="country[shops_attributes][3][position]">
<label for="country_shops_attributes_3_position">Position</label>
<br>
<input id="country_shops_attributes_3__destroy" class="destroy_field" type="hidden" value="false" name="country[shops_attributes][3][_destroy]">
<a onclick="remove_fields(this); return false;" href="#">remove</a>
</p>
は、あなたがたがそのサブ要素で異なると、各<li>
をほぼ繰り返されるわかります。
[UPDATE 1] は、ここではいくつかのラフなHTMLです。 と.sortable_shop_item_position
の値が2
の<li>
を削除すると、.sortable_shop_item_position
を.not_sortable
に置き換えて、再ソート時にこのクラスがスキップされるようにしたいと考えています。
ページのHTMLを含めると非常に便利です。 –
'$(link).prev("。sortable_shop_item_position ")'式の結果は何ですか?それはどんな要素も含んでいますか? –
@AnthonyGrist:HTMLで更新されました。 – Victor