필자는 요소를 클릭하면 draggable 및 resizable div에 내 페이지를 추가하고 컬렉션에 요소를 삽입하는 requirejs 및 백본에 응용 프로그램이 있습니다. 크기를 조정하거나 요소를 드래그하면 div 또는 height와 같은 새로운 값을 갖는 요소의 데이터를 업로드하려고합니다. 가능하니?백본 jqueryUI 컬렉션 업데이트
내 생각은 무엇입니까?
define(['jquery' ,
'backbone',
'jquery_ui',
'models/design',
'collections/design',
'views/element',
"text!templates/design.html"
],
function($, Backbone, jQueryUI, DesignModel, DesignCollection, ElementView, tmplDesign){
var DesignView = Backbone.View.extend({
initialize: function(){
this.$el = $('#layout');
this.template = tmplDesign;
console.log('initialize DesignView');
this.collection = new DesignCollection();
var here = this;
$('#insert-dynamic-element').click(function(){
//json to the collection with data t update
var element = { name:'img', type:'image', width:'100px', height:'50px' };
here.collection.addElement(element);
here.render();
$(function() {
$('.drag-item').draggable({
snap : true,
cursor : "move",
delay : 100,
scroll : false,
containment : "parent"
}).resizable({
containment : "parent",
stop: function(e, ui) {
var width = ui.size.width;
var height = ui.size.height;
//I want update this value of width and height into the collection
}
});
});
});
},
render: function(){
var template = _.template(this.template, {elements:this.collection.toJSON()});
this.$el.empty();
this.$el.append(template);
}
})
return DesignView;
});