Posts

Showing posts from October, 2014

Date Comparison: datejs Hang!

Image
Background I've always had issues working with diverse date formats using javascript till when recently I found this great resource at www.datejs.com . It was a welcome relief as it could parse almost all the date formats I wanted to parse. Today, however, I ran into a snag! The .isAfter() function stated in the datejs documentation wasn't just working for me. I kept getting error "method not found". Solution After lots of trial and research, I found out that the link posted on the datejs website most recent build is actually not the most recent build and several methods were not available in that. In case you have a similar issue, please download the most recent build from http://www.datejs.com/build/date.js and get your headache alleviated totally! It worked for me.

Multiselect Magic

Image
Background: I had this clever multiselect control for listing items that the user could select many entries from at any given time. I even made it look cool by implementing the Bootstrap Multiselect Plugin by David Stutz. However, when it was time to fetch the values of selected elements, I thought of looping through the elements to pull their values into an array. This would be inefficient and consume a lot of overhead! Solution: Turns out simply calling the javascript val() function on a multiselect returns an array of all values selected! e.g $('#selProgrammes').val() could return ["1", "2", "4", "6"] for example. Isn't it cool!

Almighty Grep

Image
Background I used to know the grep command in Linux as a powerful file searching utility. Its so powerful that it even helps search the content of files. I had a challenge today, I needed to populate a select control with the ordinals of certain numbers, precisely the number of floors in a building. Because I already have the number of floors in a public variable which is an array object, I do not wish to reach out to the server to fetch this value again, in order to save execution time; especially for end users with slower links. Solution $scope.Hostels is my public array object and it has the following structure: { "ID": 1, "ClientiD": 2, "HostelName": "sample string 3", "HostelLocationID": 4, "Description": "sample string 5", "Gender": "sample string 6", "Cordinate": "sample string 7", "Istertiary": true, "IsSecondary": true,

AngularJs Partial Page Controller Code not Executing

Image
Brief So I setup my new web application. I'm developing a web app for Hostel Room reservation and allocation. At my frontend, I'm using a bootstrap framework powered by AngularJs. Hmm! I so much love AngularJs with the ease of use it helps me to present end users of my apps. The Issue I setup a controller for most of my partial pages, however, for one of the pages (clients.html) whose controller (clientCt) is in clients.js, the script doesnt run if I navigate to the page using a link. However, if I reload the entire page while on this partial page, the script would run. Problem I found out that statements in document ready were the ones not getting executed. So, please guys, for your controller Javascript, steer clear of that ever useful document ready block: The Document Ready block $(document).ready(function(){}); Solution: I simply moved my page initialization codes outside the document ready block and pronto! Everything goes back to normal

Welcome Message

Okay, for all nerds and computer programming enthusiasts, hence forth, I will be sharing with you my challenges day to day and what I did to resolve them! Happy coding