JQuery UI 可排序 - 是否可以动态更改占位符(例如,更改为不同的 class),具体取决于它结束的容器?
JQuery UI Sortable - Can the placeholder be dynamically changed (to a different class, for example), depending on the container it is over?
我想在可排序项目超过特定大陆时更改占位符 class。到目前为止我用过这个:
$(".list").sortable({
items: ".item",
over: function (event, ui) {
// For brevity, the calculation of condition has been omitted as it is irrelevant to the question.
if( condition === true ){
$(this).sortable( "option", "placeholder", 'new-placeholder-class' );
}
},
placeholder: ".placeholder-class"
}).disableSelection();
我收到这个错误
Error: this.options.placeholder.update is not a function
知道怎么做吗?
最后我弄清楚了如何进行占位符交换。而不是:
$(this).sortable( "option", "placeholder", 'new-placeholder-class' );
我用过:
$(ui.sortable).removeClass("placeholder-class").addClass("new-placeholder-class");
如果在可排序定义的 'over:' 事件函数中定义,这将在特定可排序容器上更改占位符 class。
我想在可排序项目超过特定大陆时更改占位符 class。到目前为止我用过这个:
$(".list").sortable({
items: ".item",
over: function (event, ui) {
// For brevity, the calculation of condition has been omitted as it is irrelevant to the question.
if( condition === true ){
$(this).sortable( "option", "placeholder", 'new-placeholder-class' );
}
},
placeholder: ".placeholder-class"
}).disableSelection();
我收到这个错误
Error: this.options.placeholder.update is not a function
知道怎么做吗?
最后我弄清楚了如何进行占位符交换。而不是:
$(this).sortable( "option", "placeholder", 'new-placeholder-class' );
我用过:
$(ui.sortable).removeClass("placeholder-class").addClass("new-placeholder-class");
如果在可排序定义的 'over:' 事件函数中定义,这将在特定可排序容器上更改占位符 class。