backbone.js - BackboneJS - get specific value from Model using .max -



backbone.js - BackboneJS - get specific value from Model using .max -

so have this:

var competitionmodel = new competition.competitionmodel(); competitionmodel.contest_id = this.contest_id; this.insertview('.comp', new competition.view({model: competitionmodel})); competitionmodel.fetch();

so far good, model , (selected) values getting display in <div class="comp">.

now want specific value same model, in case profile_image , has max value model. read .max()-method dont know how utilize it

i have structure:

<div class="image"></div> <div class="comp"></div>

1) possible? 2) can utilize same methods? this.insertview('.image', blablab)

so, help me out?

ok, judging comment property array of things.

you cannot utilize backbone max (which applies collections) can utilize underscore max (they same thing, in end, former wrapper latter let's not go details). can see collection .max() in action here.

you should able this:

var max = _.max(competitionmodel.get("property"));

eventually can pass function transform values:

var max = _.max(competitionmodel.get("property"), function (element) { // element single item in list, homecoming number here. });

alternatively can utilize underscore wrapper this:

var max = _(competitionmodel.get("property")).max(function (e) { ... });

more on max() can found in underscore docs.

backbone.js

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -