backbone.js

Marionette.js CollectionView, only render specific models

China☆狼群 提交于 2020-01-12 07:53:06
问题 I am refactoring my Backbone.js application to use Marionette.js, and I am trying to wrap my head around a CollectionView . Suppose I have several ItemView s with the model Cow : // Declare my models. var Cow = Backbone.Model.extend({}); var Cows = Backbone.Collection.extend({ model: Cow }); // Make my views var GrassPatch = Marionette.ItemView.extend({ tagName: 'div', template: "<section class='grass'>{{name}}</section>", }) var Pasture = Marionette.CollectionView.extend({}); // Instantiate

Setting up a RESTful service for Backbone.js with apache and windows

对着背影说爱祢 提交于 2020-01-12 05:50:31
问题 I'm trying to set up a RESTful web service on my apache localhost to serve as the back-end for my backbone app. I have tried: Setting up WebDAV, but get the following error messages in the logs [Thu Feb 23 21:46:17 2012] [error] [client 127.0.0.1] Unable to PUT new contents for /clusters/19. [403, #0], referer: http://ideas.localhost/ [Thu Feb 23 21:46:17 2012] [error] [client 127.0.0.1] An error occurred while opening a resource. [500, #0], referer: http://ideas.localhost/ Using Backbone

Routing problems with Codeigniter and Backbone.js

拥有回忆 提交于 2020-01-12 03:53:24
问题 Here are the frameworks I am using: Codeigniter Codeigniter REST API Require.js Backbone.js Running the app: The htaccess file redirects everything through the Codeigniter index.php file. There is a default route setup in Codeigniter to call the "Start" Controller. The Start Controller calls the Start View (the only view in Codeigniter ). The Start View holds the template for the entire website and makes a call to start Require.js Require.js starts up Backbone and app works as expected.

Retrieve rails/devise current_user from Backbone

孤街醉人 提交于 2020-01-12 02:05:37
问题 I have an app where I manage the sign up/in/out with Rails through Devise. When I'm logged in, i'm redirected to Dashboard#index where Backbone start. I would like to retrieve somehow my current_user.id and current_user.token in Backbone. My only idea is to have this in my dashboard.html.haml :javascript window.App.current_user.id = "#{current_user.id}" window.App.current_user.token = "#{current_user.token}" 回答1: (Just beware that only public information should be accesible in the client side

Retrieve rails/devise current_user from Backbone

独自空忆成欢 提交于 2020-01-12 02:05:33
问题 I have an app where I manage the sign up/in/out with Rails through Devise. When I'm logged in, i'm redirected to Dashboard#index where Backbone start. I would like to retrieve somehow my current_user.id and current_user.token in Backbone. My only idea is to have this in my dashboard.html.haml :javascript window.App.current_user.id = "#{current_user.id}" window.App.current_user.token = "#{current_user.token}" 回答1: (Just beware that only public information should be accesible in the client side

Retrieve rails/devise current_user from Backbone

你离开我真会死。 提交于 2020-01-12 02:05:09
问题 I have an app where I manage the sign up/in/out with Rails through Devise. When I'm logged in, i'm redirected to Dashboard#index where Backbone start. I would like to retrieve somehow my current_user.id and current_user.token in Backbone. My only idea is to have this in my dashboard.html.haml :javascript window.App.current_user.id = "#{current_user.id}" window.App.current_user.token = "#{current_user.token}" 回答1: (Just beware that only public information should be accesible in the client side

How to generate model id's with Backbone.js

橙三吉。 提交于 2020-01-11 15:23:51
问题 I am setting up the backbone sync mechanism and am a bit confused where to generate the id's for the models. When I create a new model, should backbone be generating and setting the id, or am i supposed to implement an id generation method, or is there some sort of mechanism where I "PUT" the data to the server, which generates the id and returns a model with the id? 回答1: or is there some sort of mechanism where I "PUT" the data to the server, which generates the id and returns a model with

Backbone.js - change not triggering while the name change

点点圈 提交于 2020-01-11 14:47:47
问题 In my backbone function, while the name get change the change function not at all triggering.. any one suggest me the right way to get it.. (actually i need to get changed stuff and need to update); code : (function($){ var list = {}; list.model = Backbone.Model.extend({ defaults:{ name:'need the name' }, initialize:function(){ this.bind('change:name', function(model) { console.log('Model->change()', model); }); } }); list.collect = Backbone.Collection.extend({ model:list.model, url : 'data

Capture scroll event on div

让人想犯罪 __ 提交于 2020-01-11 09:24:27
问题 I'm trying to capture the scroll event within a Backbone.Marionette.CompositeView, but without success. As an exercise, I'm rewriting http://www.atinux.fr/backbone-books/ using Backbone.Marionette. As you can see, when you scroll down, more books are fetched and displayed (i.e. infinite scroll). However, I'm unable to capture the scroll event on my view. Here's my (simplified) code: LibraryView = Backbone.Marionette.CompositeView.extend({ // properties, initializer, etc. events: { 'scroll':

Underscore rendering [object HTMLDivElement]

五迷三道 提交于 2020-01-11 07:39:19
问题 I have an underscore template that is appending the following text " [object HTMLDivElement] " , but it's supposed to append value that "model.get('title')" returns. Here's my template: <script type="text/template" id="todoTemplate"> <div class='todoBlock'> <li class='appendedTodo'> <%= title %> </li> <button class='delete'>Delete</button><p> </div> </script> Here's my function: addTodoLi: function(model){ var todoData = model.get('title'); var compileTemplate = _.template( $('#todoTemplate')