Tag: backbone.js

How can I fake Collection data?

What I mean by this is I want to create it artificially. This is for testing purposes. But for models, it is quite simple. I just set defaults I instantiate the model object and from there I can use this.model.toJSON() to grab the created data. I want to use this same trick with collections. Is […]

Add custom menu item on wordpress 3.9.1 media upload

I’m trying to add a menu item on Media Uploader of WordPress. It is like this screenshot: Basically, it should have the same functionality of Create Gallery with just different shortcode output. I’ve search Google for hours now and this has the closest thing of what I want: https://gist.github.com/Fab1en/4586865 But it has an error which […]

How to handle Javascript error in Jasmine framework?

How to handle Javascript error(s) in Jasmine framework like syntax error, etc? TypeError: undefined is not an object (evaluating $(‘{DIV_ID}’).css(‘paddingTop’).replace) Is it possible to catch any of Javascript (Backbone.js) critical errors in Jasmine.js?

XML error on Chrome but is fine on FF?

I’m using PHP to retrieve data and publish the data as an RSS feed. The script I have works fine on Firefox but not on Chrome. This works on Firefox but not chrome: getData.php?id=1744225&odds=1 This works on Chrome: getData.php?id=1744225&odds=1 Chrome seems to need the full ampersand code in the URL: “&” The full URL is […]

How to use nested models with Backbone Forms List? I want to make a nested model with custom template

How do I use nested models with Backbone Forms List? I want to make a nested model with a custom template, but this is giving an error: “Render of undefined” I want to make a view by backbone-forms with a custom template. The template is <div class=”container-fluid add-apikey” data-class=”add-apikey”> <div class=”page-head”> <h2>API Key</h2> </div> <div […]

Using iframe body as Region in Backbone Marionette

I’m trying to use an iframe‘s body as a Region in Backbone Marionette. Marionette uses standart jquery selectors to define which element is the region, like this: App.addRegions( { main: “#main-region” } ); I want my region to be the body of an iframe, which normally I would find like so: $(‘iframe’).contents().find(‘body’); When trying to […]

Best(?) practice for loading & saving relational data in Polymer

What is the best, or just a good, practice for loading and saving relational data in Polymer elements’ published properties? I’ve used https://github.com/PaulUithol/Backbone-relational to load and save relational data. It depends on Backbone. But now with Polymer’s use of Object.observe(), I mostly don’t need Backbone’s complex model objects (at least I don’t need their get() […]

Handlebars isn't getting exported?

Problem When executing the compiled handlebars templates the global Handlebars object isn’t exported. NOTE: the global Backbone object is working. See, when the code App.templates.todos attempts to execute in the todos.js file it fails because App.templates.todos isn’t defined. Well ultimately that’s because the third line in the templates.js file can’t execute because the global Handlebars […]

Backbone.js not working with Require.js bundle

I can’t get Backbone.js to play nicely with require.js’ bundle system. This works: requirejs.config({ baseUrl: ‘assets/’, bundles: { corejs: [‘jquery’, ‘underscore’] }, paths: { corejs: ‘../core’, jquery: ‘../static/js/jquery’, backbone: ‘../static/js/backbone’, underscore: ‘../static/js/underscore’, knockout: ‘../static/js/knockout’, knockback: ‘../static/js/knockback’ }, shim: { backbone: { deps: [‘underscore’, ‘jquery’], exports: ‘Backbone’ } }, deps: [‘corejs’] }); require([‘app/app’], function(App) { App.initialize(); […]

Backbone.Collection has too many elements after save

I use Backbone with Marionette and backbone-relational. Let’s say I have a zoo with a Backbone.Collection of animals. I have one animal stored in the database (with the id 1). Now I add a second animal to the Backbone.Collection and call zoo.save({}, {wait: true}). In response my backend server returns both animals (the old one […]