There is no _major_ problem, but the syntax can be terrible.
May be I'm wrong but, the main problem for me was to access the current instance of a class.
1st level : use this
2nd level : var self=this; then use self;
3rd level : var sefl=this; and pass self as parameter.
Typically, when a new view appear, I load dynamically the resources nee: other javascript files and an HTML template file. I use jquery to handle AJAX.
Here is some code:
ConsumptionView.prototype.show = function(){
var self=this;
var files=[];
var tests=[];
files.push('/static/js/date.js');
tests.push('Date.prototype.setISO8601');
mainApplication.run_after_dependencies( files, tests,
function() {
$('#content').load("/static/html/user_consumption.html",
function(){ self.htmlLoaded(self);});
});
}
the `run_after_dependencies` function will mostly do some getScript only if needed. The last function will do (mostly):
$.getScript('/static/js/data.js', function() {
$('#content').load("/static/html/user_consumption.html",
function() { self.htmlLoaded(self);}
);}
);
But in the end, I _have_ to pass 'self' in parameter to 'htmlLoaded' function and I cannot use the 'var self=this;' at the top of the definition of the function html_loaded.