I wanna know if there is a way to call a function after rendering the view by backbone. The problem is that, the function I want to call need an html element rendered by backbone. indeed, I'm using 'ipywidgets' python module, which allows the creation of custom widgets which are exactly backbone views.
Here is the view code:
var TestView = widget.DOMWidgetView.extend({
render: function() {
var template = _.template( $("#editor_template").html(), {} );
this.$el.html(template);
this.model.on('change:value', this.backToFront, this);
//return this;
},
backToFront: function() {
//$("#editor").val(this.model.get('script_ldp'))
editor.getSession().setValue(this.model.get('value'));
console.log("python change value " + this.model.get('value'));
},
events: {'click':'frontToBack'},
frontToBack: function(event){
this.model.set('value', editor.getSession().getValue());
this.touch();
console.log("js change value " + this.model.get('value'));
}});
this piece of code will display an html textarea on the page, and after-done, I should transform this textarea to something else(ace editor) by getting it from the DOM by it's 'id'.
If I do that: document.getElementById('textarea_id_returned_by_render')
it returns null
. I also tried that by it didn't work for me, it can be because of the python module I'm using, I mean that I'm not using pure backbone.js.