Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Is it a good practise to have one base model and call different finaAll for all?

$
0
0
So I have many sections to access thorught the dom elements, but all contain the same set of parameters.

say sections would be A, B, C, D and each section is in the html with same set of parameters.

So is it fine having a single base model say Base.model(
basemodel = can.Model.extend({
findAll : function(params){
return $.ajax({
url: '/api.php',
datatype: params.data,
dataType: 'json'})
}
},{})

and then for each just call A = can.Control.extend({can.view('images/js/mn/temps/featured.ejs', basemodel.findAll({
url: "",
datatype: ''}).then(function(d) { return { offerdata : d, secTitle : that.element.data('title') }; })).done(function(frag) { that.element.html(frag); }) }}
})
And same for the B C D with overriding findAll parameters.

Also is it best practise to have a single base controller and then override it with different parameters and function calls.

Viewing all articles
Browse latest Browse all 3491

Trending Articles