I’m using this coffeescript code:
in a spec file:
index = new MeetingIndex(render: false, collection: booking.meetings)
index.render(writeTo: '.sandbox')
in the view file:
render: (options = {}) ->
console.log 'options'
console.log options
console.log 'options'
options[key] ||= val for key, val of writeTo: 'body', enhanceUI: true
the browser console prints:
Object
enhanceUI: true
writeTo: "body"
What could be happening here?, how can I pass parameters to render method?
You’re just being fooled by an asynchronous
console.log. Your firstconsole.logcall is just grabbing a reference tooptionsbut by the time it tries to log it, you’ve already updated it. Try this instead:Demo: http://jsfiddle.net/ambiguous/EZc7N/