Answer the question
In order to leave comments, you need to log in
How to apply jQueryUI plugin to a view?
I'm trying to connect the plugin after the MarionetteJS show event, but onShow fires before the view is rendered to the DOM.
onShow: function () {
$('.drag-el-container .col-div').draggable({
containment: ".t-container",
revert: true,
revertDuration: 0,
start: function () {
$( this ).css({
width: 180,
height: 685,
position: 'relative',
background: '#f1f1f1'
});
},
stop: function () {
$( this ).css({
width: 364,
height: 60,
position: 'relative',
background: 'transparent'
});
}
});
$( ".cols-div" ).droppable({
accept: ".col-div",
tolerance: "pointer",
over: function( event, ui ) {
$( this ).addClass('hover');
},
out: function( event, ui ) {
$( this ).removeClass('hover');
},
drop:function( event, ui ) {
$( this ).append(ui.draggable);
$( this ).removeClass('hover');
}
});
}
Answer the question
In order to leave comments, you need to log in
Try using not $
, but this.$
when searching for a selector. In the second case, the search will be conducted inside this.$el
the view, which by the time the callback is called onShow
has not yet been inserted into the DOM, and then your selectors $( ".cols-div" ), $('.drag-el-container .col-div')
do not work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question