AppGini and BackboneJS
Posted: 2016-08-07 19:02
Today I was playing a little with Backbone.
It's something interesting, but I'm not sure if has some value far than using only Views.
It allows to write something like this for a form:
As far as I see, well, is cool because all visual logic could be in only one place, listening events, but I don't see how to get more potentional of Backbone from Collections, and so on, because Backbone "needs" a RESTful service.
Somebody did more testing?
It's something interesting, but I'm not sure if has some value far than using only Views.
It allows to write something like this for a form:
Code: Select all
var AlmacenesView = Backbone.View.extend({
events: {
"submit form": "formHandler",
"click #ref": "aclick",
"change #ref": "onChangeRef"
},
formHandler: function(evt) {
evt.preventDefault();
var nombreAlm = $j('#ref').val();
this.$el.append('<p>hello: ' + nombreAlm + '</p>');
$j('#ref').val('<p>hello: ' + nombreAlm + '</p>')
},
onChangeRef: changingRef,
aclick: function(evt){
console.log(evt);
}
});
function changingRef(){
var nombreAlm = $j('#ref').val();
$j('#ref').val('OMG ' + nombreAlm);
}
$j().ready(function(){
var myForm = new AlmacenesView({el: $j('.container')});
});
Somebody did more testing?