Getting Chrome to prompt to save password when using AJAX to login

Starting with Chrome 46 you don’t need iframe hacks anymore! All corresponding Chrome issues have been fixed: 1 2 3 Just make sure that the original login form does not “exist” anymore after a push state or an ajax request by either removing (or hiding) the form or changing it’s action url (didn’t test but … Read more

Choosing the right UI templating tool – dust.js? [closed]

Dust.js is a good option. It is better than some of the other templating frameworks because it does not constrain that the data should be in a file, or in a string, etc. Also it is being actively maintained https://github.com/linkedin/dustjs. Has it been successful? Yes, I know at least LinkedIn is using it and also … Read more

What is use of tagName, id, and className properties in Backbone View? While we can access dom element with el

Those properties are used if your view has to create its own element, that is, if it doesn’t have a el attribute when instantiated (various reasons, I can go further in the matter). So you’ll have a new element with the id id, classes className and attributes attributes. You can find the relevant piece of … Read more

Extending the defaults of a Model superclass in Backbone.js

The problem is that Inventory.prototype.defaults and Extended.prototype.defaults has the same reference, because you have not override the reference. So you can do this in 2 ways, maybe more but i only found this 2: Edit: The first example is incorrect (see comments); please refer to the second. var ExtendedInventory = Inventory.extend({ defaults: { rabit:25 } … Read more

Global error handler for backbone.js ajax requests

Backbone’s sync triggers an ‘error’ event when errors occur. So one approach you could take is to extend Backbone’s Model and Collection objects to add these add-on error checks. It would look something like this: ErrorHandlingModel = Backbone.Model.extend({ initialize: function(attributes, options) { options || (options = {}); this.bind(“error”, this.defaultErrorHandler); this.init && this.init(attributes, options); }, defaultErrorHandler: … Read more

Backbone.js Error Handling – how do you do it?

In my ears this sounds a bit on the complex side, at least to start with. Backbone.sync will already report errors that you can catch in your models .save() method: this.mymodel.save(/* … */, {success: function(model, result, xhr)…, error: function(model, xhr, options)…} (docs). If your serverside follows HTTP specs well, the error code is already provided … Read more

Backbone.js model with collection

Your parse() function shouldn’t set() anything, its a better practice to just return the attributes, Backbone will take care of setting it. e.g. parse: function(response) { response.summaryList = new JobSummaryList(response.summaryList); return response; } Whatever you return from parse() is passed to set(). Not returning anything (which is like returning undefined) is the same as calling … Read more