FAQ Database Discussion Community


How to pass Backbone event handler function as string?

jquery,backbone.js,backbone-views,backbone-events
I have a Backbone view (SearchView) which have several search handlers. The search handler function must be dynamically passed as a string based on some process type. Here is my code SearchView = Backbone.View.extend({ el: wrapper, process : "defaultHandler", event: {}, template: _.template("<div id='cpntainer'><input type='button' id='search' value='Click Here'/><div>"), initialize: function(options){...

Backbone Performance - Collection with a view per model or only one view for the whole collection

performance,backbone.js,backbone-views,backbone-collections,backbone-model
If a have a collection with 50 models, it seems that I have 2 main options to render a list displaying 50 models: - Option1 : Create a specific "item view" for each model and append these views to a main "list view". This will provide a direct relationship between...

Marionette CompositeView Sort Rendering

backbone.js,marionette,backbone-views
I have a Marionette (2.4.1) CompositeView and when I do a sort it re-renders the entire view rather than the childView. The header icons revert back. I could fix them on render but is there a way that I can just render the childView? diaryEntries = Backbone.Marionette.CompositeView.extend({ template : diaryEntries,...

cordova app gets refreshed when trying to upload image, using the image picker plugin inside a form

cordova,backbone.js,backbone-views,cordova-plugins,cordova-3
when i try to add images inside a form using the image picker plugin, the app get refreshed. But when i try to add image outside the form it works fine. Can anyone please guide me what am i doing wrong? this is what i have tried <form id="formDemand" enctype="multipart/form-data"...

Handle Views in routing backbone js

backbone.js,backbone-views,backbone-routing
What is the best way to switch to a different view when user navigates to a different url. In angular there is ng-view that takes care of this and inserts corresponding templates and in ember its all route based. Is it better to just hide other views elements on routing...

Backbone JS - Combination of collection, views and models

backbone.js,backbone-views,backbone-collections,backbone-model
I had the following setup now in three different projects, so I thought maybe it's worth asking here. There's a chance I'm not the only guy wondering about this. So there it comes: I have a list of objects The list items have a special function like draggable or onClick-Events...

Backbone js view render click method not calling [Very Basic]

javascript,backbone.js,backbone-views
I am a toddler to backbone js, born yesterday actually.. Following this tutorial - https://www.youtube.com/watch?v=_6pBvMK1Qgo I am trying to execute this simple view code, but somehow the render method not getting called - <script type="text/javascript"> model = Backbone.Model.extend ({ data : [ {text : "Google", href : "www.google.com"}, {text :...

Is there a way to iterate through all of the views in Marionette?

backbone.js,marionette,backbone-views
I really want to go through every view programmatically and trigger all of their click events, is there a way to do this?

Can a Marionette.js Behavior trigger an Event?

javascript,backbone.js,marionette,mobile-website,backbone-views
I have a Behavior in Marionette that handles the logic for detecting swipe events. My subviews each incorporate this behavior to know when a swipe gesture has occurred on them. My question is once my Behavior has determined a swipe has occurred, how does it get this information out to...

Passing arguments on top of those passed by trigger() in backbone.js

javascript,backbone.js,underscore.js,backbone-views,backbone-events
I have a method that passes up an argument in a nested view in Backbone, like such: page.get('condition') ? this.trigger('someEvent', object) : this.trigger('someOtherEvent', object); As I understand it, this code will pass object to 'someEvent' or 'someOtherEvent' as the first argument to the callback specified in the listener for that...

Backbone Multi Step Modal

javascript,jquery,backbone.js,backbone-views,backbone-routing
I'm creating a Twitter Bootstrap multi-step modal. This is how I'm trying to get the workflow to work: User clicks on button to open modal... modal opens User types in access code, clicks next Server checks if access code exists. If it exists user moves on to next step in...

How to watch for variable changes in Backbone

javascript,backbone.js,backbone-views
I have a view which has a property called headerClass which I define at the top of the view and in various methods I change the value by doing this.headerClass = 'new value'. But how can I watch for changes to this variable? I tried add this.headerClass.on("change", this.render, this); but...

Dynamically adding columns to BackGrid inside a Marionette view

marionette,backbone-views,backgrid
So, I have a complicated Marionette app with several composite views. I am attempting to add a dynamic BackGrid to the view, but can't seem to get it to add columns. I create the grid and add it to the view as per this post: Backgrid integration. However, it appears...

Backbone view listening to model, not firing on change or reset?

backbone.js,backbone-views,backbone-events,backbone-model
I am using a model to fetch location data from a service using POST. However I am struggling to get the view to listen to that model when it finally receives a response. Note I have overriden some model methods to fit the service I am using. Model code define([...

Change event fired instead reset in backbone view

javascript,backbone.js,backbone-views,backbone-events,backbone-collections
I'm trying to execute my reset event in view through cllection fetch but it doesn't working... router: var tablesCollection = new TablesCollection(); var tablesView = new TablesView({ collection: tablesCollection}); tablesCollection.fetch({ reset: true }); My view: initialize: function(){ _.bindAll(this); this.collection.bind('reset', this.render); this.collection.bind('add', this.addTable); this.collection.bind('change', this.changeTable); this.collection.bind('destroy', this.delTable); }, render: function() {...

Get id of another view in Backbone

javascript,backbone.js,backbone-views,backbone-routing
I have two views, one of them have a search box that includes a button "Search" with id="search". In the second view I want when click in button "Search" make a search. But for this happens I need to get the id. How can do this? Here the code of...

Call a new View from another View in Backbone

javascript,backbone.js,backbone-views
I'm a complete newbie to JS and to the Mongo/Mongoose/Express/Node/Backbone/Require stack... so there is a lot to learn and It's entirely possible I missed something here. However I am trying to store the result of a submitted form then move the user onto a different view if the save action...

How to access object from parent in custom if helper?

javascript,backbone-views,handlebars,handlebarshelper
The ../../Message.NotAvailable in the ifequal helper doesn't seem to work but if i provide a string "Hello" to compare with type it works fine and comes inside the loop {{#ifequal type ../../Message.NotAvailable}} <li id="{{id}}"><a href="#">{{../../../Message.NotAvailable}}</a> </li> {{/ifequal}} My helper: Handlebars.registerHelper('ifequal', function(value1, value2, options) { if(value1 === value2) { return options.fn(this);...