Tuesday, 1 October 2013

How to return the value of a key: function() in javascript

How to return the value of a key: function() in javascript

Here is what I have inside a backbone model:
defaults: {
prayer_string: function (){
var label_val = $("#prayer_type_label").val();
console.log("Prayer_string returning: ", label_val);
return label_val;
}
}
But when I access the model like so:
var prayerString = model.prayer_string;
prayerString is the function and not the return label_val.
What do I need to do to get the return value of the function instead of
the function itself?
Thanks,
Andrew

No comments:

Post a Comment