Skip to main content

Posts

Adding beforeRender and afterRender functions to a Backbone View

I was working on a Backbone application that updated the DOM when a response was received from the server. In a Backbone View, the initialize method would perform some operations and then call the render method to update the view. This worked fine, however there was scenario where in I wanted to perform some tasks before and after rendering the view. This can be considered as firing an event before and after the function had completed its execution. I found a very simple way to do this with Underscore's wrap method.

Some useful Underscore methods

I like jQuery and I use it in all my projects. Lately I've been looking into Design Patterns and Backbone framework. Backbone has a dependency on Underscore and more often than not, people use Underscore as a client-side templating engine when using Backbone. I was looking at the Underscore documentation and came across a bunch of useful methods.

Goodbye 2012

2012 has just gone by and all I can say is that, it has been yet another eventful year. The biggest thing that happened to me was my new job at Myntra. It has been two months since I joined my new employer and I'm liking my new work. I had started last year with a few goals (I don't like calling them as resolutions) and the very first one was to reduce weight. I had met with an accident in 2011 (a terrible one) and had to stay at home for two months. And by staying at home and munching all that good food, I had put on some extra weight and wanted to loose it desperately. I think I almost cleared that goal and now I'm proud of it.

Applying MVC to your frontend application using Require and Backbone

I've been looking into BackboneJS for quite sometime now and thought it would interesting to build an application using the MVC pattern. Although Backbone provides various components - Models, Collections, Routers and Views; it doesn't provide a framework that can help you to structure the application using these components. While working on this application, I realized that I can separate these components in such a way that they can be made reusable or rather loosely coupled by defining the components in separate files. However, there was an interesting problem that I came across where the Views had a dependency on the Collections to be loaded first and then render the template data. I had read a little about RequireJS that allowed modules to be loaded asynchronously and also in resolving dependency. Thought I would give it a try and see whether it addresses this problem.

Using Routers in Backbone.js

After taking a break for a few days and then joining my new employer, I'm writing this long pending post on Routers in Backbone. A Router can be considered as a Controller in a MVC application. Controller in any MVC application defines how the incoming request should be handled. For example, a Servlet in a J2EE application accepts the request and looks into the configuration and delegates the request to one of the handlers.

Hello Myntra

Another big announcement today. I've joined Myntra.com which is India's largest online fashion store. I've ordered stuff from Myntra a few times in the past and it has always been a great experience buying from them. Now that I'm working with them, I'll buy more :) More importantly it's a new day and beginning of a new journey. I'm all excited about my new job and I hope to learn a lot in coming days. Wish me luck!!

Good Bye Adobe

The title says it all. Today was my last working day at Adobe and I've decided to pursue my career elsewhere. I've spent more than three and half years at Adobe, working as a part of the ColdFusion Engineering team. Over the last few years I've learnt a lot from the team, from the ColdFusion community and from many others at Adobe. I've developed interests in HTML5, JavaScript and other related technologies and frameworks and I've decided to pursue my interests.

Backbone.js - Creating a RESTful CRUD application

I've been trying to build a CRUD application using Backbone.js and was able to retrieve a set of records into a collection using the fetch method . To perform other operations i.e. Create, Update and Delete I could always invoke Backbone.sync but I was exploring on the lines where this is performed implicitly. The fetch method sends an implicit GET request on url specified in the Collection, similarly I was looking for other methods that allow you to send POST, PUT and DELETE requests to the url. While I was building this application, I did come across a condition where Backbone was not sending a request. I was finally able to figure out as to why that happened and then it was a simple fix in my Backbone application as well as in the REST service.