I guess I am missing something very basic here. I just want to get the value from the function in coffeescript. I am doing console.log for that value..
class App.Views.PlotModal extends Backbone.ModalView
template: JST['plots/plot_modal'],
render: ->
console.log(@getSize.w);
$(@el).html(@template(plot: @model));
this.showModal();
getSize: ->
cell_div = document.getElementById("bgr");
w : cell_div.offsetWidth * 3;
h : cell_div.offsetHeight * 2;
When I go to console in firebug I keep getting undefined. If I log just @getSize, I get the function back. How do I return the variables w and h here?
Also is it a good idea to do this kind of operation (I want to dynamically resize iframe) in backbone view?
In CoffeeScript, this leaves the method
fin the variablexas a simple function:If you want to call the function then you have to supply arguments:
or add parentheses:
So you want this:
As far as doing this sort of thing in Backbone goes, sure, why not? Backbone tends to leave policy up to you.