jQuery UI 1.9 マイルストーン 7 の時点で、jQuery UI スピナーのベータ版を使用しています。 jQuery セレクター (.spinner)。これらのスピナーは、一連のオブジェクトの値を設定しています。これらのオブジェクトはすべて、リソースの同じ「プール」から取得されます。スピナーの値が更新されるたびに、そのリソース プールの残り量に基づいて、すべてのスピナーの最大値を調べて更新したいと考えています。これまでの基本的なコードは次のとおりです。
var unusedPool = 500;
jQuery(document).ready(function($) {
$('.spinner').spinner({
min: 0,
max: (unusedPool + this.value),
change: function(event, ui) {
// An AJAX call which pushes the change to the DB,
// and returns a JSON object containing the change in what remains
// in the resource pool.
jQuery.ajax({
// URL, type, etc. etc.
data: { newValue: this.value },
success: function (data) {
unusedPool -= data.change;
// Here is where I need to go through and update *all* spinners,
// so their new "max" is their current value plus the new
// unusedPoolSize.
}
}
}
});
私がやろうとしていることをする方法はありますか?イベントをすべてのスピナーにバインドしてからそのイベントをトリガーする必要がありますか、またはすべてのスピナーにアクセスして「最大」値を変更するためのより直接的な方法 (変更コールバック内) はありますか?