backbone.js

custom BackboneJS events(increment and Decrement) not working

吃可爱长大的小学妹 提交于 2020-02-07 04:39:48
问题 I am having a counter(No. of products) that I want to manipulate using backboneJS custom events. If I click Add Product then No. of products should increase by and if I click Remove Product then No. of products should decrease by one.Demo here The problem is, value of counter is not getting updated when i click buttons. here is code snippet var Counter = Backbone.Model.extend({ defaults: { value: 10 }, // model methods increment: function() { this.set({value: this.get('value')+1}); },

Backbone.js with servlet as backend

痴心易碎 提交于 2020-02-05 13:09:33
问题 I'm very new to backbone Js. I have gone through the documentation. I'm trying to create a sample aplication with servlet as the backend for saving models. I could not find any help for that. What i need is: is it possible to communicate with servlet? And if so, how to communicate with servlet? (some sample code) is router required to communicate with server? 回答1: Backbone is a client side framework. Its build to work with a RESTful backend. So all you need is a backend that can compute GET,

jQuery Autocomplete Plugin using Backbone JS

蓝咒 提交于 2020-02-03 10:19:29
问题 Let's suppose I want to use jQueryUi for implemeting autocomplete in a backboneView having a form. I implement the following code (*), but I don't like it because the fetching of the collection is performed also when the user does not type any letter. How should I perform the fetching collection only when the user starts to type something in the input box? var MyView = Backbone.View.extend({ initialize: function () { this.myCollection = new MyCollection(); this.myCollection.fetch(); // I

Rendering collection view in backbone.js

天大地大妈咪最大 提交于 2020-01-31 16:34:29
问题 I am having problems understanding how to render a collection in a view using a template. Here is my code: <div id="mydiv"></div> <script type="text/template" id="details"> <ul> <% _.each(?, function(person) { %> <li><%= person.name %></li> <% }); %> </ul> </script> <script> var m = Backbone.Model.extend(); var c = Backbone.Collection.extend({ url: 'retrieve.php', model: m }); var v = Backbone.View.extend({ el : $('#mydiv'), template : _.template($("#details").html()), initialize : function()

Rendering collection view in backbone.js

南笙酒味 提交于 2020-01-31 16:32:54
问题 I am having problems understanding how to render a collection in a view using a template. Here is my code: <div id="mydiv"></div> <script type="text/template" id="details"> <ul> <% _.each(?, function(person) { %> <li><%= person.name %></li> <% }); %> </ul> </script> <script> var m = Backbone.Model.extend(); var c = Backbone.Collection.extend({ url: 'retrieve.php', model: m }); var v = Backbone.View.extend({ el : $('#mydiv'), template : _.template($("#details").html()), initialize : function()

Backbone js collection of collections issue

狂风中的少年 提交于 2020-01-29 03:56:05
问题 I'm running into an isssue when I try to create a collection of collections using backbone js. Here is the code : Models and Collections : var Track = Backbone.Model.extend({ defaults : { title : "" } }) var TrackCollection = Backbone.Collection.extend({ model : Track, }) var Playlist = Backbone.Model.extend({ defaults : { name : "", tracks : new TrackCollection, } }) var PlaylistCollection = Backbone.Collection.extend({ model : Playlist, }) Creation of the playlist collection : var playlists

Overide Backbone sync globally with Browserify

筅森魡賤 提交于 2020-01-25 20:18:12
问题 var servicesNew = { readUrl :"", deleteUrl :"", updateUrl :"", createUrl :"", primaBackbone : function(method, model, options) { options || (options = {}); var beforeSend = options.beforeSend; options.beforeSend = function(xhr) { xhr.setRequestHeader('Authorization','Bearer 52b20db1-4bcb-426e-9bbf-a53a826249f3') if (beforeSend) return beforeSend.apply(this, arguments); }; // passing options.url will override // the default construction of the url in Backbone.sync switch (method) { case "read"

Backbone js Model Save more than once

馋奶兔 提交于 2020-01-25 16:23:29
问题 Iam learning Backbone js and so I have started creating sample application. BTW, iam facing one problem now ie., model is saving more than once in my database. I mean when you click ' Create User ' , you'll see a form, so when I click that 'Create User' button, details are getting saved more than once in my DB and so all duplicate users info displayed in the home page. Actually iam trying to practice this video: https://www.youtube.com/watch?v=FZSjvWtUxYk The output would look like this: http

Backbone js Model Save more than once

北城以北 提交于 2020-01-25 16:21:02
问题 Iam learning Backbone js and so I have started creating sample application. BTW, iam facing one problem now ie., model is saving more than once in my database. I mean when you click ' Create User ' , you'll see a form, so when I click that 'Create User' button, details are getting saved more than once in my DB and so all duplicate users info displayed in the home page. Actually iam trying to practice this video: https://www.youtube.com/watch?v=FZSjvWtUxYk The output would look like this: http

Backbone Collection get Object

守給你的承諾、 提交于 2020-01-25 15:36:22
问题 not well versed in Backbone, so understand if I don't explain this completely. I have a collection I am trying to retrieve. Here is an example of the JSON: { "id" : "section-one", "href" : "section-one-baseball", "divisions" : [ { "name": "Orioles", "division" : "AL East" } ] } My problem is that I can't figure out how to get to the sections name. When I put this in the console: BaseballTeams.models[0].get("divisions") I get back an Object with the name and the division. But if I put this in: