Hi all,
First off, thanks for a great JS MVC framework, I've been using JSMVC for a few projects and am now embarking on our first CanJS project.
Secondly, as implied, I'm quite new to CanJS so hope this isn't too dumb of a question.
Anyway, I had a query about Control instantiation/initialisation. In the docs, it seems like this is the way to instantiate a control:
var data_view = new Portal.DataView('.latest-updates', {
view: '//portal/controllers/data_view/views/latest_news.ejs'
});
So far so good. However what I've found is that if ".latest-updates" doesn't returns a zero-length nodelist, i.e. it doesn't match anything, the control still initialises (i.e. runs the prototype init method). Is this expected behaviour?
My init method do a lot of work, so to avoid unnecessary work being done, I do this:
init: function (el, options) {
if(el.length == 0) return;
......
....
}
Any discussion, opinions or answers would be much appreciated,
Thanks in advance,
Bryon