Dzulqarnain Nasir

  • June 18, 2012

    When not to use the statement

    So today a colleague of mine ran into a small JavaScript problem. One of his functions ran an Ajax request which returns a JSON object which is parsed using jQuery’s parseJSON method. The resulting array is then ran through another function which does some calculations and displays the results in a list.

    Here’s where the problem starts. The method that does the calculations runs through the array using the native JavaScript loop, in which a calculation method is applied to every item in the array. However, for some reason, the list contained one extra item with the value NaN. Upon inspecting the array, I found that there was an extra item called map, which was a function. You can probably already guess by now why the calculation didn’t work as it was expected to, and rightly so, especially when the value used in the calculation was a function.

    Read more »
  • May 15, 2012

    EPiServer CMS: Custom top menu for multiple plugins

    I’ve been working on this small plugin for EPiServer CMS 6, and I wanted to add it to a custom top menu created by another plugin that I had helped develop. I wanted to append the link for my plugin into the same top menu as that other plugin. The only requirement is that my plugin will still display the same top menu even if the other plugin is not installed.

    Unfortunately, after a lot of time Googling and forum crawling, I came to the conclusion that it was just not possible to append an item to a top menu dynamically. I didn’t bother looking at solutions that involved me editing the project’s web.config file, which may have helped, since the other plugin already had some code which adds a top menu item to the top menu bar. So I figured I should probably try to use that instead.

    Read more »
  • May 11, 2012

    Object doesn't support this action - For In Loop and IE

    I’ve recently encountered a problem in Internet Explorer when I was using a for-in loop in one of my scripts. It was a simple loop too.

    for (item in data) {
        $, data[item]);

    This piece of code will attach a data property for each JSON object it receives from an Ajax request. Simple, right? This works in every other browser I’ve tested it on, EXCEPT Internet Explorer.

    Turned out the word item is a reserved word or something an IE method, because when I swapped item with something else, like j or _item, the code immediately works.

    Read more »
  • May 02, 2012

    Get Nested Property Of An Object

    I was working on a small filtering script for a GMaps project, and I needed to create a filtering method to filter markers based on their properties. The catch is, the filtering method has to be able to filter out markers based on several types of properties. Not all at once though.

    So obviously I can write a separate method for all the types of filter material required. Every method will grab all the markers on the map, iterate through them, filter out the irrelevant markers, and return the results. But that would result in code duplication, and that’s not how I roll. So instead, I created a single function that handles the filtering, and one method that allows you to get property of nested objects using their property path.

    Read more »
  • March 16, 2012

    Twitter Bootstrap in IE8 - 'eval' is null or not and object

    I’ve recently decided to move onto LESS for my current and future projects, after seeing how simple CSS can be using LESS. So I downloaded Twitter Bootstrap 2.0.2 and Less.js 1.3.0 and included them in Visual Studio. Mind you, you might need to install Mindscape Web Workbench to be able to add LESS files via the Add New Item window. You can get it via Visual Studio’s Extension Manager.

    Anyway, after “installing” LESS into my project, I ran some tests. I opened up Rockmelt, my default browser, and lo and behold everything worked just like it did using standard CSS. Then I opened the same project using Internet Explorer 8 (I seem to be the only one at the office who still uses IE8) and I was greeted with this error.

    Image of the error

    Read more »