FAQ Database Discussion Community


Success callback function is not called

backbone.js
I`m building a simple backbone application, and have a problem with success callback function in my View. Here is a code var EditUser = Backbone.View.extend({ el: '.page', render: function(option){ var that = this; if(option.id){ that.user = new User({id : option.id}); that.user.fetch({ success:function(user){ var template = _.template($("#edit-user-template").html()); that.$el.html(template({user: user})); } });...

Persisting data client side for event driven approach

javascript,backbone.js
I have an application that renders activities and looks like this: The map should render markers based on some criteria (date_start, date_end, map_bounds). Activities are loaded from a REST api with ajax. The front end approach is event driven (using Backbone / Marionette); activities are dynamically udpated when the date...

Backbone js routing on page load/refresh without hash

javascript,backbone.js
I have this in my router # ROUTING App.Router = Backbone.Router.extend( routes: '': 'homePage' 'photography': 'photographyPage' 'about': 'aboutPage' 'contant': 'contantPage' initialize: -> that = this @route 'photography', 'photographyPage', -> that.photographyPage() pageWrapper = $('#pageWrapper') content = $('#content') homePage: -> console.log 'homepage' photographyPage: -> console.log 'photography' ) After I initiate the router...

Can we provide two entry points for single page application?

jquery,backbone.js,single-page-application
I am working on a Single Page Application. Our first page is login page where we enter username and password. Now client gave us a new requirement to provide a seperate login page for admin users. There should be an extra drop down list in Admin Login page. They need...

Backbone datatypes - type casting?

javascript,backbone.js
It just took me over an hour to find out that a Backbone query on a collection was failing because I queried the wrong data type. So this query failed because I used the wrong data type for id: element = collection.findWhere({id: "123", att: true}); This one worked and returned...

Backbone JS: Fetching a collection – trouble with JSON response format

backbone.js
I have some trouble with the initial population of a collection in Backbone JS. While developing myCollection didn't fetch the data from a server, I just passed it in like this: app.myCollection.reset([ { person: 'Sally'}, { person: 'Peter'}, { person: 'Paul'}, { person: 'Wilma'} ]); Doing a console.log(app.myCollection); showed me...

Creating/Accessing Global object with requirejs and backbonejs

javascript,object,backbone.js,requirejs,globals
This is presented in easy to understand fashion, so enjoy reading :) I have a backbone app which is initialised with main.js file like this: require([ 'backbone', 'app', 'models/session' ], function (Backbone, Application, SessionModel) { //new Application(); window.App = { session: new SessionModel() }; new Application(); Backbone.history.start(); }); As you...

How to inherit and add events in child in backbone.js

javascript,backbone.js
I have tried this solustion but couldn't get it working. So situation is there a parent which doesn't have any event defined. I can not make any change in parent. I can make changes only in child modules so I need to have two child modules both adding a different...

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...

CSS attribute to backbone el view

javascript,html,css,backbone.js
Is it possible in backbone to add an empty attribute such as data-equalizer: <div class="row" data-equalizer> My backbone view looks like this: MyApp.Views.UserPanelInnerContainerView = Support.CompositeView.extend({ className: "row", initialize: function(){ }, render: function(){ } }); I can add class of row using className, but how do i add data-equalizer?...

Backbone.Deferred.Model: Why the unittest is not run?

backbone.js,coffeescript,phantomjs,mocha,chai
Here is the code in question. define (require) -> Backbone = require 'backbone' require 'backbone-deferred' class Data extends Backbone.Deferred.Model urlRoot: 'data' parse: (resp) -> resp.record or resp isValid: -> @get 'valid' # Newly introduced dataUrl: -> @get('data_url')?.replace /abc/, '' And here is the unit test define (require) -> Data =...

passing backbone collection to view

grails,backbone.js,handlebars
I'm just starting out with backbone / grails and i've been struggling to figure out how to get everything to work. I'm building a pricing configurator where a user selects a product type from radio group A and radio group B containing the quantity / pricing / discount data will...

What is the correct way to override Marionette compositeview render

backbone.js,marionette
I am showing a table view using Marionette's composite view. The composite view's template has a tbody with an initial which shows a loadding animation gif. Now, when the render method is called, I want to remove this initial row and then append the results of collection fetch. However the...

Backbone.js collection fetch not setting response objects as models

backbone.js,collections,fetch
When fetching a collection, my api response has 10 objects, but the resulting Backbone collection only has 1 model with an attributes array containing the 10 response objects....to put it another way, the fetch is not creating models out of the objects in my response...and I don't know why. Model...

Listening for route events in Backbone not working – attached function is not called

javascript,backbone.js
In a Backbone JS project, I am trying to listen for events emitted by the router. From the docs: When the visitor presses the back button, or enters a URL, and a particular route is matched, the name of the action will be fired as an event, so that other...

Backbone: How to render template to DOM?

javascript,backbone.js
I am new to Backbone and having difficulties with rendering a template. The template itself is as unspectacular as this: <script id="messageTemplate" type="text/template"> Message: <%= content %> </script> The Backbone view & model look like this: var Message = Backbone.Model.extend({ defaults: { content: 'Default message' } }); var MessageView =...

Grab data attribute from an event

javascript,jquery,backbone.js
I have a jQuery event which is part of a backbone class that I am trying to grab the data-attribute from called 'data-foreground' My function looks as follows.. foreground: function(e) { if (e.target.id === "") { this.findClickedElement(e, "li"); return false; } console.log(e.target.id); // this returns the id which is '115'...

How to use variables in Backbone events object?

javascript,backbone.js
Currently my code looks like this: events: { 'click .update-url': 'update_url', 'click .show-password': 'show_password' }, but for touch devices I want to use touchstart instead of click as the event hence I want to use variables like this: var click_event = is_touch_device ? 'touchstart' : 'click'; ... events: { click_event...

What is the use of HTML5 pushState in Backbone History Start method

javascript,html5,backbone.js
I have a simple Backbone app. I am trying to understand the difference created by passing pusState: true when starting Backbone.History object. JavaScript var r = new (Backbone.Router.extend({ routes: { "users": "allUsers", "users/new": "createUser" }, allUsers: function () { v.render("showing all users"); }, createUser: function () { v.render("showing form for...

Backbone's success callback called before jquery's ajaxSuccess

jquery,ajax,backbone.js,callback
I would like to make sure that jQuery's ajaxSuccess callback is called before Backbone's success, which is not the case in my experience. I would like this someModel.fetch({ success: function() { console.log('2'); } }); $(document).ajaxSuccess(function(event, xhr, ajaxOptions) { console.log('1'); }); to log 1, 2 and not 2, 1. The reason...

What is the default element for Backbone view?

javascript,html,dom,backbone.js
When I use this this.setElement($('#some-id')); in backbone's view, what am I changing the element from? The parent DOM?...

How to let Webpack require a root node_module instead of an child package?

backbone.js,npm,webpack
I have installed backbone and backbone.babysitter trough npm. When I use backbone in my scripts like this: import Backbone from "backbone"; It loads the installed backbone version 1.2.1. This works fine until I want to use backbone.babysitter. When backbone.babysitter loads it needs to add properties to backbone itself. But the...

Backbone.js - Model's attribute is not getting passed to view correctly

backbone.js
I am very new to backbone and trying to understand why "title" is not getting passed to view and printing correctly. If I create model with title properties it passes to view and prints fine. Any pointer will be greatly appreciated. HTML: $(document).ready(function(){ //Model var Appointment = Backbone.Model.extend({ urlRoot :...

Underscore templates with Backbone

javascript,backbone.js,underscore.js,underscore.js-templating
I'm completely new in backbone framework. I have a model itemsOnSaleModel that contains an array of items and a View itemListView that render these items. The problem is that I can't figure out how to write the template correctly. Usually in this case I would have written something like this:...

What is my backbone version?

javascript,backbone.js
I couldn't find it on here or looking through google. I might be doing my search wrong, but can anyone tell me how to find out the version of backbone I'm using. I tried backbone --version, but that doesn't seem to work I'm also using browserify, if that makes a...

Backbone JS: Rendering template without something like $('body').append?

javascript,backbone.js
Using an external template, I am trying to render a Backbone JS view to the DOM. Unfortunately, I only get a blank screen, while checking with the console confirms that everything is working. To get the rendered template in the DOM, I have to do something like $('body').append(myView.render().el);, which according...

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...

Handlebars: return hash from helper

javascript,backbone.js,coffeescript,handlebars.js,handlebars
Can i return hash from Handlebars helper? I tried this: In my view: initialize: -> super this.hash = {key1: 'test1', key2: 'test2'} Handlebars.registerHelper 'show', => return this.hash In template: {{show.key1}} What am i doing wrong? Thanks!...

Add two events in backbone.js

javascript,jquery,backbone.js
I added two jQuery events, the second jQuery event is not triggering. What might be the issue? Here is my code : var ListView = Backbone.View.extend({ events: function() { $('#couponcheck2').click(function(e) { e.preventDefault(); $('#couponcheck').empty(); $('#couponcheck').append('<div class="col-xs-8"><input type="text" class="form-control" id="enterCoupon"></div>'); $('#couponcheck').append('<div class="col-xs-8"><button type="button" class="btn btn-success btn-sm" id="couponbutton"><span...

bacbone marionette pass variable to view method

javascript,backbone.js,marionette
I have simple situation and can't understand why variable that I pass to function always undefined. var ProjectItemView = Backbone.Marionette.ItemView.extend({ template: "#ProjectItemTemplate", initialize: function () { var id = this.model.get('project_id'); $.getJSON('service/api.php/projects/' + id + '/progress').done(function (data) { this.renderProgress('4'); //<== pass here }); }, renderProgress: function (why) { alert(why); //<== undefined...

How to access Rails configuration info in Backbone View?

javascript,ruby-on-rails,backbone.js,stripe-payments
I'm trying to implement Stripe into a Rails app with a Backbone front end. In a normal rails view, I can do this: <%= form_tag charges_path do %> <article> <label class="amount"> <span>Amount: $5.00</span> </label> </article> <script src="https://checkout.stripe.com/checkout.js" class="stripe-button" data-key="<%= Rails.configuration.stripe[:publishable_key] %>" data-description="Launch Survey" data-amount="<%= @amount %>"></script> <% end %> And...

Backbone Collection only fetched after executing alert

node.js,backbone.js,express,handlebars.js,jade
Hey I am new to backbone and Handlebars and something strange is happening with my code that I cannot figure out. Basically my node app queries mongo for some data which is then used by backbone and handlebars to relay the data to the user. When I try to relay...

Backbone events between view and controller

javascript,backbone.js
I'm trying to use Backbone events in a Model-View-Controller pattern. My controller is just a JavaScript class, so I've extended it like this to support Backbone events: function Controller() { _.extend(this, Backbone.Events); this.listenTo(view, 'some:event', this.onSomeEvent); this.onSomeEvent = function() { // ... This code never executes. } } My view is...

“Cannot read property 'appendChild' of null” with Disqus on Backbone website

javascript,backbone.js,disqus
I have a website on Backbone. When I try to execute Disqus code i get Uncaught TypeError: Cannot read property 'appendChild' of null How can I fix it? Why is this happening? var disqus_shortname = 'mysite'; /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var...

CollectionView - collection data not being passed to childView

javascript,backbone.js,marionette
I'm trying to make the collectionView work , but I'm not really sure whether the CollectionView initiates the fetch method automatically and then populates the ChildViews with the fetched data. Or is it something I need to do manually? I have checked the Marionette doc page but I couldn't find...

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([...

Use jQuery show() with complete function and no animation

javascript,jquery,animation,backbone.js
This question is in addition to jQuery toggle() with no animation... In order to avoid animation on show of element, I'm trying to replace below 2 lines var that = this; this.$el.show("fast", null, function(){that.updatePosition()}); with following, this.$el.show(); this.updatePosition(); Is it possible that function updatePosition will be called before current element...

how to use bootstrap mergeCells dynamically in backbone.js

javascript,twitter-bootstrap,backbone.js,bootstrap-table
I have a function which creates a bootstrap table and i have to merge only specific columns in that table dynamically. this.$('#Table1').bootstrapTable({ striped: false, minimumCountColumns: 2, smartDisplay:true, clickToSelect: false, columns:[ { field:'Key2', title: $.t('report:'+code+'.Col2'), align: 'left', valign: 'middle', sortable: true, events : this.linkEvents formatter :this.linkFormatter } ] }); linkEvent function:...

Comparison Express JS, Angular JS vs Backbone JS [closed]

angularjs,backbone.js,express,requirements
I am starting to learn node js for a while and it seem amazing. When I start to apply nodejs to build a scalable website, I am wondering to do Express for back-end, BackBone Js or Angular JS for front-end, people said Express JS is very fast, while Backbone.js seem...

Backbone: reverse string comparator

javascript,backbone.js
Backbone has a nifty little comparator feature that just takes a attribute name as a string and sorts by it. I would now need to sort by this but in descending order. var Chapter = Backbone.Model; var chapters = new Backbone.Collection; chapters.comparator = 'title' // sorts by title, ascending chapters.add(new...

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,...

Backbone adding more events after render?

javascript,jquery,backbone.js,backbone-events
How do I add more events after rendering a collection to a view. I have a list of all the element Ids which need an event binded to them. Currently I am trying to use jQuery onclick to trigger a callback to a function in my view. The problem though...

Data to be passed along with an event under Messaging pattern architectire

javascript,design-patterns,backbone.js
Is it a good idea to pass a model or a collection data in a message on every event. E.g. messageBus.on('someEvent',modelData); and the subscriber than receives the data. Or it is better to have kind of service (JS module) which would store and update the data on a model/collection throughout...

Backbone render template in side el's nested id

javascript,jquery,backbone.js
I have my html setup like this. <div id="product-module"> <ul id="product"> <li><input name="product" type="radio"/></li> <li><input name="product" type="radio"/></li> <li><input name="product" type="radio"/></li> </ul> <table id="quantities"/> <script id="myTemplate" type="text/x-handlebars-template"> {{#each this}} <tr> <td class="quantity"> <label class="checked" for="quantity_{{id}}"> <input type="radio" value=""...

Are models (as in Backbone or Ampersand models) really necessary with React?

javascript,backbone.js,reactjs,ampersand.js
I come from a Backbone / Marionette background and have been working in React for a few weeks now. A lot of people say you should pair React with something like Backbone or Ampersand.js, using React as the V and Backbone / Ampersand as the "M" and "C" in the...

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() {...

Tool tip on Header of Backgrid Table

javascript,backbone.js,marionette,backgrid
I am using backgrid to display a table. I want to show tool tip on header of the table. can any one help?...

Marionette CompositeView - change in template each nth items

twitter-bootstrap,backbone.js,marionette,composite-view
I'm using Marionette for a while, but I'm not sure how I can do what I want, in a simple manner. I have a composite view, which renders something like this: <div class="row"> <div class="col-xs-12"> <div id="items"></div> </div> </div> Each of my item is being rendered as a: <div class="col-xs-3">foo</div>...

Backbone.js remove model from collection

javascript,backbone.js,backbone-collections
I'm learning Backbone and for the life of me I can't remove a model from a collection. The collection 'remove' event fires, but the collection appears to remain the same. Here's what I have so far: http://jsbin.com/becamo/edit?js,output I remove the model from the collection upon click. Then, the list view...

Backbone localstorage - A “url” must be specified (without view)

backbone.js
I know there are more similar questions like this, but I really couldn't find the answer to my problem.. Here is my jsfiddle: http://jsfiddle.net/ktyghnL1/3/ Code: var Todo = Backbone.Model.extend({ }); var Todos = Backbone.Collection.extend({ model: Todo, localStorage: new Backbone.LocalStorage('todos-backbone'), comparator: 'order' }); todos = new Todos(); I am only using...

Do backbone marionette.js parent view bubble down?

javascript,backbone.js,marionette
I reference this question and document I know how to bubble up. But in my situation, I want to bubble down. Just like I click a button on parent view then trigger some function of all my childview. var parent = Marionette.CompositeView.extend({ triggers: { 'click #edit': "??" // trigger the...

Extend Coffeescript subclass function from parent in marionette

javascript,backbone.js,coffeescript,marionette
I've got a "FormView" class in my Marionette application that sets up a lot of things for form submissions around my app. I use it every time there is a form. I've also got some helpers that I want to pass into every form template via the templateHelpers method, but...

function: why are all children updating in this backbone collection?

javascript,backbone.js,collections
I have a Backbone collectionView that holds x amount of companies. I also have a collection of x amount of products. I want to get a random product and add it to a list of "assets" on a random company. (the company is returned from the this.getRandomCompany() function) But when...

Updating variable through model Backbone

javascript,backbone.js,model-view-controller,updatemodel
I have a base model, that is creating a view with several div's. It is not actually a form; but it is acting as a form. I have variables being set with defaults as well. Here's my model right now: var BaseModel = require('base-m'); var SomeModel = BaseModel.extend({ defaults: function()...

Merge two object arrays for Chart

javascript,arrays,backbone.js,lodash
I've two arrays which I'm going to merge and then load in chart. range = date array generated from moment.js, there is date of every day in example one month or specific date range with one another attribute count: "0" data = fetched data from database through backbone Now I...

Setting a src value into an iframe

javascript,backbone.js
I'm trying to set a src value into a Backbone View with an element of iFrame. This src value comes from the Model but it doesn't render properly. It returns Not Found The requested URL was not found on the server. If you entered the URL manually please check your...

BackboneJS : the model is fetched, but toJSON() and get() methods don't work [duplicate]

javascript,backbone.js
This question already has an answer here: View's collection only working in console.log 3 answers Still learning Backbone, here is my code const API_URL = 'http://api.brewerydb.com/v2'; const API_KEY = '********************************'; var Categories = Backbone.Model.extend({ url: API_URL + '/categories/?key=' + API_KEY }); var CategoriesView = Backbone.View.extend({ tagName: 'ul', id: 'categories',...

Wrong result for filtering by substring

javascript,backbone.js
I am creating a filtering input where brings the results according to keyUp. This is what I am doing for filtering, through a Backbone's Collection: var Brand = Backbone.Model; var Brands = Backbone.Collection.extend({ model: Brand, filterByName: function () { return this.filter(function (model) { return model.get('name').indexOf('h') > -1; }); } });...

Parse.com To Do web app deployment issue

javascript,backbone.js,web,parse.com,cloud
Apologies for basic question. I am very new in web development . I have download parse.com javascript web To Do App from https://parse.com/tutorials/todo-app-with-javascript . Now I want to deploy with parse.com. So that I can browse this app using http://mytestapp.parseapp.com. But when try to deploy using "parse deploy" command getting...

How to define events dynamically in backbone.js

javascript,events,backbone.js,dynamic
I have more click events inside my view like events:{ 'click #link1':'showDetails', 'click #link2':'showDetails', 'click #link3':'showDetails', 'click #link4':'showDetails', 'click #link5':'showDetails', 'click #link6':'showDetails', 'click #link7':'showDetails', 'click #link8':'showDetails', 'click #link9':'showDetails', 'click #link10':'showDetails', 'click #link11':'showDetails', 'click #link12':'showDetails', 'click #link13':'showDetails', 'click #link14':'showDetails', 'click #link15':'showDetails', 'click #link16':'showDetails',...

webpack CommonJS backbone and underscore

javascript,backbone.js,underscore.js,webpack
I'd like to use Backbone with webpack in the CommonJS style, but I need to understand how to: Tell webpack that Backbone depends on underscore Prevent them from automatically defaulting to AMD It seems like imports-loader might be the answer. Do I want something like this in my configuration? module:...

Dropzone.js status is pending and not uploading a file

javascript,node.js,backbone.js,express,dropzone.js
I am using Multer in back-end to handle file upload and Dropzone.js in front-end. Everything is fine when I use Postman to test my back-end code, but in when I use Dropzone the status is pending and file not getting uploaded. Then after 4 minutes of waiting I get Timeout...

Backbone.Marionette + Rails app redirects after form submission. Why?

javascript,ruby-on-rails,forms,backbone.js,marionette
I have a sample app that I'm working on that uses Ruby on Rails for the server backend and Backbone.Marionette for the client-side. The main functionality is a form to "order a widget". I'm using backbone-forms to create the form. The oddity that is throwing things off is that once...

Can't call fetch directly in Backbone model listenTo

javascript,backbone.js,coffeescript
I'm trying to have a model listen to a collection and fetch itself when the collection changes: class Team extends Backbone.Model urlRoot: '/team', initialize: function(attributes, options) { this.listenTo(members, 'change', this.fetch) The fetch does seem to trigger, but the url is all messed up, and to get it to work I...

backbone stickit - reverting model changes

javascript,backbone.js,2-way-object-databinding
I'm now testing backbone stickit for two-way data binding. Is there a way to revert the changes, for example, while editing a model data through a form, the user press the cancel button, as in the pic below It seems the model was changed on the fly as we type...

Determine if field (on submit event) is a dropdown or a input

javascript,jquery,forms,backbone.js,model-view-controller
My issue is that on my button that is named submit; I want to save data to my model from the view once the submit button is clicked. I want to store each field input into an object so I can store the data in my model. The issue is...

$(window).bind('load' … ); not triggering

javascript,jquery,backbone.js,requirejs
I'm currently working at making a web application only open one instance. This is being done with cookies that are being set/checked when the app is loaded and removed when the app is closed. My logic for setting the cookies I've already worked out, but I'm having a problem getting...

CSS Selector Equivalent Of jQuery.find in backbone.js?

javascript,jquery,backbone.js,selector
I have a Marionette view that has the following code: onRender: { $('#someDiv').find('a').click(function(){ // some code here }); } But I want to refactor to something like this: events: { 'click [selector here]': 'executeCode' }, executeCode: function() { // some code here } Is this possible?...

Javascript DOM elements hide class and the element not present are same?

javascript,backbone.js
I am currently working on a project where most of the code has been written by someone else . I was supposed to do some slight modifications in the existing script to incorporate changes in a new file. I came across a situation where it was very confusing . The...

Bacbone Marionette how to get access to an element in which the view is wrapped up?

jquery,backbone.js,marionette,collectionview
I have CollectionView which has tagName and Id/tagClass. I heed apply plugin to 'tagName' element on onRender event. I can't access it through this.el. var ListView = Backbone.Marionette.CollectionView.extend({ tagName:'article', className:'myClass', id:'myID', childView: ListItemView, onRender: function () { (access to view tagName el).readmore({ speed: 500 }); } }); ...

Backbone's delegateEvents doesn't bind events until after attached to DOM

javascript,jquery,backbone.js,marionette
I'm working on a chat client, and I've come across an issue with Backbone's event system. When the client starts, I render the view as so: var view = new ServerListView({collection: Chatter.servers}); Chatter.Views.servers = view; $('#channels > ul').html(view.render().el); Works fine, events are called. Speaking of events those are: events: {...

Can't find element using UI hash in Marionette Layout

javascript,jquery,backbone.js,marionette
I'm not sure why I can't get the button element using my UI hash. This is what my Layout looks like: Layout: App.Base.Objects.BaseLayout.extend({ // Rest of the code left out for brevity ui: { btnSave: "#btnSave" }, events: { "click @ui.btnSave": "onSave" }, onInitialize: function () { this.listenTo(App.vent, "DisableSaveButton", function(val)...

Marionette - listenTo a custom event triggered from a collection

javascript,backbone.js,marionette
I'm using a Event Aggregator(EA) to keep track of all events in my app. But there is one situation I could not make the EA listen to a custom event triggered from a collection. See more details below. eMgr (Event Manager i.e Event aggregator): define(['backbone.wreqr'],function(Wreqr){ "use strict"; return new Wreqr.EventAggregator();...

Can I use Backbone with React Native?

javascript,ios,backbone.js,reactjs,react-native
I have found several different examples of integrating React (View) with Backbone on the web, but not any to do the same with React Native. I was wondering if this was possible and also if there were any samples to play with. This (https://github.com/magalhas/backbone-react-component) also seemed a good starting point,...

How to access models inside Backbone Marionete App?

javascript,backbone.js,marionette
actually i'm a backend developer so be gentle if my question is so dumb :) I have an Backbone app initialized like this: var AgendaApp = Mn.Application.extend({ onStart: function() { ... ... var bookings = new Bookings(); bookings.startStream({ remove: false }); } var agendaApp = ... As you see bookings...

How to detect model parameter change event in mithril.js?

javascript,backbone.js,mithril.js
I recently started learning mithril.js and I'm wondering how can I make very basic Model -> View one way data binding app. TestModel = function(data){ this.name = m.prop(data.name) } testModel = new TestModel({name: "John"}) code above declare a model and it works perfectly as getter/setter. but how can I set...

Backbone - remove last model in Collection, but only by filter

javascript,backbone.js,underscore.js
this.keysCollection.pop(); Removing the last one is pretty simple, but what I'd ideally like to do is this (pseudo solution): this.keysCollection.pop({ type: 'foo' }); And for it to remove the last matching model from the Collection. Possible? EDIT: Went with this - const models = this.where({ type: 'foo' }); const model...

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 persistent login - login removed on browser quit

javascript,rest,authentication,backbone.js,login
I am working on a backbone application that hooks into RESTful API. One problem I having at the moment, is that a user can be logged, they can then close there browser, reopen it go to my application and be logged out. Is is possible to make a login persistent...

How to disable backbone.js from adding /# when dialog is closed

javascript,jquery,ruby-on-rails,backbone.js,zurb-foundation
When I load my backbone page, and press back button it adds /# to the url. If I click back again it loads the empty index page from rails home view. I was able to resolve this issue by turning off turbolinks. However, when I open any foundation.js dialog, it...

Delete single model from collection in Backbone.View

javascript,backbone.js,collections,model
var PlayersView = Backbone.View.extend({ collection: players, //collection of players el: "#playersList", //I bind to the class render: function () { this.$el.html(""); for (var i=0; i<this.collection.size(); i++) { var player = this.collection.at(i); this.$el.append("<li "+"value='"+player.get("id")+"'>"+player.get("names")[0]+" "+player.get("surnames")[0]+" <a href='#' class='edit'>[edit]</a>"+"</li>"); } //what I render is in the picture below return this; }, events:...

Backbone this.el is undefined

jquery,backbone.js
I've been following along to the a tutorial i found on youtube. https://www.youtube.com/watch?v=vPW1inIsln4 In the tutorial I don't see him defining el : ... but he's calling this.$el and it appears to be working. In jsfiddle, I have been following along, but get a js error saying Backone this.el is...

Passing data to view template is undefined in Backbone.js?

javascript,backbone.js,underscore.js-templating
All, I am trying to pass a simple JSON object for the time being (tried with a model but still the same problem). I have initialised my View as such with a variable called "skills" which I want to pass into my template. However inside the template it is saying...

Backbone with Multipage node app strategy

node.js,backbone.js,requirejs
I have a question regarding the node app that I want to build. Before starting on the development, I've written a clear document that splits up my app into different components: Home Search User profile Dashboard etc... Each of these modules may in turn consist of different submodules. As every...

Backbone Model object has undefined prototype property during fetch [duplicate]

javascript,backbone.js,prototype
This question already has an answer here: Backbone.js collectin throw the error 1 answer I am attempting to define a Backbone collection and then use Backbone.fetch to pull data from an API. But when I run fetch on the collection, I end up getting this error: When I inspected...

Passing a Marionette Application through requirejs

backbone.js,requirejs,marionette
file structure app | |--scripts | | | |--home | | | | | |--index.js | | |--object.js | | |--router.js | | |--views.js | | | |--app.js | |--main.js How do I get the Router file: router.js require([ 'jquery', 'backbone', 'app', 'marionette'], function($,Backbone,UserAdmin) { return Backbone.Router.extend({ routes:{ "":"showIndex" },...

Input pattern regexp validation, JS add commas, allow user add commas and validate it

javascript,regex,html5,validation,backbone.js
I have search a lot, I can make almost all tasks separately, but all together ... So, I have input with type="text" <input type="text" pattern="^[1-9]|^[-,0-9]{2,18}$" class="form-control commas-decimal-points" id="tot-uniques-display-<%%= model.adPartnerId %>" placeholder="eg. 100,000,000" name='network_data[display][total_monthly_uniques]' value="<%%= model.display.total_monthly_uniques %>"/> pattern="^[1-9]|^[-,0-9]{2,18}$" This pattern validate only for number, not more than 14 digits, not allow...

Backbone JS: Where does parameter representing model in collection view come from?

javascript,backbone.js
I am in the process of learning Backbone JS. While I feel like I made great process so far, there is one thing I don't understand. Take the following collection view: App.Views.Tasks = Backbone.View.extend({ tagName: 'ul', render: function() { this.collection.each(function(a) { var taskView = new App.Views.Task({model: a}); this.$el.append(taskView.render().el); }, this);...

View is not a constructor for Backbone under Typescript

javascript,backbone.js,typescript
I am trying to create a Backbone.js view in Typescript. I get the following error: TypeError: ExampleView is not a constructor in http://localhost:57258/Tests/spec/ExampleViewTest.js (line 17) My view is instantiated like this: var view = new ExampleView(); The view is declared like this: ///<reference path="../Scripts/typings/backbone/backbone.d.ts"/> class ExampleView extends Backbone.View { constructor(options?:...

Backbone checkbox value in tr view

jquery,table,backbone.js,checkbox,collections
I'm currently programming the web interface for a mvc web application and I need to get the models which have their checkbox checked. At the moment this is the template i use to generate a single table row: <td><span class="userintern"><%= intern %></span></td> <td><span class="username"><%= name %></span></td> <td><input id="add" class="add" type="checkbox"...

Iterate over a backbone collection based on properties of models in an elegant way

javascript,backbone.js
I have a backbone collection and based on an attribute of models inside collection I iterate over the collection and show it in the UI. The logic is, if the model has property isNewCar as true, I'll first show them all in UI, followed by a separator then i'll show...

Truncate everything after first 120 characters and refresh

javascript,jquery,backbone.js
I'm quite new to UI development. I have a textfield. (input) where the user enters a string for SMS. I want to discard all the characters which are more than 120. I have written code for this one. Problem: if the user enters more than 120 characters, how do I...

Where to format collections / objects

javascript,backbone.js,architecture,project-structure
From front end architectural point of view, what is the most common way to store scripts that perform transformations on collections of objects/models? In what folder would you store it, and what would you name the file / function? Currently I have models, views, controllers, repositories, presenters, components and services....

Collection - Model usage for JSON response?

json,backbone.js,backbone-collections
Regarding the pattern Backbone uses for Collections and Models , I am not sure if what I am trying to achieve is possible. I am wanting the Collection to act as a constructor by making a AJAX POST request to fetch JSON. Using that JSON response it will instantiate multiple...

How to remove a span element from Backbone.js $el?

javascript,jquery,backbone.js
this.$el has the following structure: <div> <span class="orWord">OR</span> <span>...</span> </div> I am trying to retrieve the span with class orWord and remove it from the DOM. In order to achieve it I tried this but it didn't work: this.$el('span.andWord').remove(); Please let me how the above span can be removed from...

Why `init` of shim in my require.js configuration not called?

javascript,django,backbone.js,requirejs,csrf
Update: I was writing a small module to handle this csrf token problem in backbone until I got push notification of @Louis's answer. His answer is quite elegant and seems nice, but I'll leave a link to my backbone.csrf module github repo just for anyone who needs it. ==================================================================== I'm...

backbone - preventing same view from overlapping

javascript,backbone.js
Let say a each row in a table got its own view and a model (CollectionViews). Each row got a button for editing the row data. When clicked an EditView is activated for the current row and model where a form is presented to the user with textfield and cancel...

How to use AngularJS/Ionic as part of Backbone/Cordova project?

javascript,angularjs,cordova,backbone.js,ionic
I am new to AngularJS/Ionic so I am asking for your helps to give us some ideas about how to add AngularJS/Ionic to part of Backbone project. We have a project on hand which is built based on Backbone framework in Cordova. Now we are looking for doing part of...

How to use multi-level Backbone Router fragments with Apache?

apache,backbone.js
I'm having troubles getting Apache rewrites to work when directly loading pages with multi-level route fragments. Here are two examples: Here is my virtual host configuration: RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) /index.html [L] Example 1: http://www.fakewebsite.com/products (working) When I...

Iterating through Models Attributes in Backbone?

javascript,json,backbone.js
I have a model that requests a JSON file like below: [ { "ModifiedOn": "2015-04-08 11:17:28.0", "BuildingCode": "AU1010A1", "BuildingName": "REGUS - BRISBANE", "ActionRequired": "A" }, { "ModifiedOn": "2015-04-08 11:17:28.0", "BuildingCode": "BR1044A1", "BuildingName": "RIO SUL - RIO DE JANEIRO", "ActionRequired": "A" }] In the console I can see the attributes like...