Destroying Custom Dojo Widgets

On March 13, 2014, in Javascript, by Anuj Gakhar

One of the things I learned today is that custom Dojo widgets do not completely get cleaned up if they have child widgets that have been programatically created. _WidgetBase’s internal call to destroy() or destroyRecursive() won’t completely destroy the programatically instantiated widgets and might leave some memory leaks. Consider this piece of code :- [js […]

Tagged with:  

Binary Search in Javascript

On March 1, 2014, in Javascript, by Anuj Gakhar

Binary Search is one of the fundamental algorithms in computer science. It is used to quickly find a value is a sorted set of data. It is also referred to as half-interval search, sometimes, purely because on each successive iteration, it halves the number of items to check. Binary search works by comparing an input […]


Converting number to words with Javascript

On February 23, 2014, in Javascript, by Anuj Gakhar

This is a little programming exercise, purely for fun. The idea is to take a number (in digits) and convert it into it’s english form. So, e.g. 1000 becomes “one thousand”, 1450 becomes “one thousand, four hundred fifty” and so on… The approach I’ve taken is as follows :- Deal with numbers less than hundred […]

Tagged with:  

Counter Textarea Dojo widget

On February 22, 2014, in Javascript, by Anuj Gakhar

There are probably hundreds of examples of textarea counter plugins out there (most of them jQuery though, but I wanted to write one in Dojo. The idea is quite simple, you want a textarea that takes a maxlength parameter and displays a counter of what’s available and does not let you enter more characters than […]

Tagged with:  

Disabling multi-selection in a Dijit Tree

On October 28, 2013, in Javascript, by Anuj Gakhar

The Dijit Tree component lets you select multiple options by default and there is no easy way to turn that off, or atleast none that I could find. Ideally, this should be a configurable property, byt sadly, that’s not the case. However, there is a “singular” property on the _dndSelector that would let us disable […]

Tagged with:  

Case insensitive sorting in a Dojo Store

On October 24, 2013, in Javascript, by Anuj Gakhar

Dojo has this concept of Store’s which is a uniform way of accessing and manipulating stored data. The Store API is a standard API implemented by all the different kinds of Stores (Memory, JsonRest etc). The Store’s query() function returns filtered data from the store based on passed in criteria and optionally also sorts the […]

Tagged with:  

Singletons in Dojo

On August 29, 2013, in Javascript, by Anuj Gakhar

I’ve been working with Dojo Toolkit for the past few months and I have started to like it actually. It is a full featured stack that includes core DOM manipulation, selectors, widgets, unit testing framework, build scripts, charting etc all combined into one big library. I just think it is not as widely as it […]

Tagged with:  

A simple TicTacToe game with AngularJS

On June 16, 2013, in Javascript, by Anuj Gakhar

This weekend, I decided to do a little practice project with AngularJS. I made a TicTacToe Game. Here are some notes about the game :- It’s a two player game, human vs computer. It uses NegaMax Search for computer moves. There are no DOM updates from the Angular controller (best practice). The controller simply changes […]

Tagged with:  

Duplicates in a repeater are not allowed in AngularJS

On June 15, 2013, in Javascript, by Anuj Gakhar

AngularJS does not allow duplicates in a ng-repeat directive. This means if you are trying to do the following, you will get an error. [js] // the below will throw an error Error: Duplicates in a repeater are not allowed. Repeater: row in [1,1,1] key: number:1 <div ng-repeat="row in [1,1,1]">[/js] However, changing the above code […]

Tagged with:  

Rounding numbers with decimal places in Javascript

On June 6, 2013, in Javascript, by Anuj Gakhar

By default, Javascript’s Math.round does not support decimal places. If the fractional portion of number is .5 or greater, the argument is rounded to the next higher integer. If the fractional portion of number is less than .5, the argument is rounded to the next lower integer. Here are 2 examples of the above :- […]


Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 297 other subscribers

© 2011 Anuj Gakhar