Archive

Archive for June, 2009

Adding Thickbox to dynamically generated links in DOM

June 28, 2009 Sriram 5 comments

From the day I started working  as a web developer,  jQuery has fascinated me. As a newbie to web development, I prefer writing plain javascript code at the moment(just to know the language better),  but just couldn’t resist trying out the jQuery-AJAX APIs. Okay, Let me get back! I’m working on a new feature for HeyMath! in which I used Thickbox, a popular and beautiful jQuery plugin, in a couple of pages. The page has a  table with one particular column containing thickbox links (<a class=”thickbox”>…</a>) There is a javascript function repaintTable(Object, tableid) which repaints the rows of the table(deletes the existing rows and inserts new rows based on data in the Object). This function takes care of applying the thickbox class to the links which appear in the table. When the page loads, a JSONObject which comes from the server by default, is passed on to this function. At this point, the links open happily in thickbox.  There are some other links in the page each of which gets a new JSONObject from the server through AJAX , when clicked. On success of every such AJAX call, repaintTable function is called with the new object(obtained as response) and the same table as arguments. After the first AJAX call,  the links stop opening in thickbox. Thankfully what is happening behind the scene is so simple. When the document is ready(page is loaded), all links with thickbox class(input,image map elements also) are selected and each of them is binded with a function on click event. I realised that this was not happening for the newly created links in the DOM. To do the same, I added a line of script tb_init(‘a.thickbox’) at the end of the repaintTable function. Now the links with thickbox class do open in thickbox, after AJAX calls :)   This can be handy whenever a small number of  thickbox links are generated dynamically. And here is an interesting tutorial about using  jQuery to manipulate and filter data in a table. There are so many ways to make the table dynamic. I hope to use this also!

Life logger #1

June 22, 2009 Sriram Leave a comment

There are a lot of things, both good and bad, that have happened since I logged out from wordpress last time, just that I haven’t penned them down. Good things first. Did I tell you that I got a bike? Yeah, a black honda unicorn. And did I tell you that I managed to ride 1700 kms in 75 days without any accidents or curses from co-riders? Riding it on the highway brings so much pleasure that I completely enjoy riding on the stretch from Chrompet to Guindy which takes about 20 minutes. After that, riding through Saidapet and Nandanam becomes a pain with lot of signals, slow movement of traffic, and people crossing the road whenever they like, showing palms as if they belong to Congress. Anyway I reach my office in 50 minutes by bike (compare it to 110 minutes byMTC).  So, after 4 years, my MCWG/LMV license found a purpose to serve other than being identity proof for SIM cards :) I learned to ride only after getting the bike but people haven’t stopped teasing me commenting about my speed. But I would never compromise on safety and fuel efficiency(mileage) for speed, especially after witnessing so many bad drivers out there !
One more surprise was that my good friend and college mate rave has shifted his house to Tambaram Sanatorium reachable in just 10 minutes from my house(of course, in bike) ;) Went to his house last week end and met him. Expecting to meet him more often !
Time to list the bad things -  Fire Accident The place was just 4 houses away from my house. The baby’s mother also died few days back, after spending nearly 2 weeks in hospital. This bizarre fire accident had a deep impact leaving me sleepless for days.
My mother’s health is still on the decline. Right from my childhood and  society even up to my college days, she used to be hyper active doing ten different things at a time. It is very sad to see such a person now becoming very passive, fighting against heart problems and low BP, chronic neck pain adding to the list. As she feels a support in me, I once again realized the importance and significance of that one decision which I took in haste – leaving Bangalore and hence Veveo (they were paying me a hefty salary) to come back to Chennai. It  happened to be one of the very few right decisions I’ve taken in my life.
Amidst all these, the urge to bring some changes in the society never left me. Recently, I joined BHUMI as an experiment. There are a number of reasons for why I wanted to try BHUMI when there are hundreds of NGOs. May need a separate post for that. But right now, no comments about it. I’ve to wait and see how different is it from NGOs, to what extent the words are translated to action and how significant is the change it brings about.

More things are there to write, especially about things I’m doing at HeyMath!  So in all probability, I won’t take much time to be back here :)