Accessibility and all these JavaScript frameworks

I use a js-framework (spine.js in my case) in my latest site. Still I make sure that non-js browsers (certainly not over zealous: think SEO) can navigate my site and digest the contents. As an example I’m going with a search-page with products being shown. Products can be paged, filtered, sorted. Of course this is … Read more

Super in Backbone

You’ll want to use: Backbone.Model.prototype.clone.call(this); This will call the original clone() method from Backbone.Model with the context of this(The current model). From Backbone docs: Brief aside on super: JavaScript does not provide a simple way to call super — the function of the same name defined higher on the prototype chain. If you override a … Read more

Backbone View: Inherit and extend events from parent

One way is: var ChildView = ParentView.extend({ events: function(){ return _.extend({},ParentView.prototype.events,{ ‘click’ : ‘onclickChild’ }); } }); Another would be: var ParentView = Backbone.View.extend({ originalEvents: { ‘click’: ‘onclick’ }, //Override this event hash in //a child view additionalEvents: { }, events : function() { return _.extend({},this.originalEvents,this.additionalEvents); } }); var ChildView = ParentView.extend({ additionalEvents: { ‘click’ … Read more

Delete multiple records using REST

Is a viable RESTful choice, but obviously has the limitations you have described. Don’t do this. It would be construed by intermediaries as meaning “DELETE the (single) resource at /records/1;2;3” — So a 2xx response to this may cause them to purge their cache of /records/1;2;3; not purge /records/1, /records/2 or /records/3; proxy a 410 response … Read more

How to improve rendering performance when using $.html()

Create a new DocumentFragment to pre-render all the items, then update the DOM once. Also, favor this.$(…) over the global jQuery selector $(…). this.$ is a proxy to this.$el.find(…) which is more efficient, and less prone to select something outside of the view. Using jQuery’s core function ($()) inside a view can fail if the … Read more

correctly implement backbone comparators

You have a few things wrong here. This doesn’t do what you think it does: if(theorder == ‘nooffers’) { Request.comparator = Request.nooffers(); } That executes the nooffers method and assigns its result to Request.comparator. But sortBy returns the sorted list: nooffers : function() { return this.sortBy(function(ab) { return ab.get(‘offers’); }); } and setting that list … Read more