May, 2008

Simple Rails helper for using OnClick on div, tr and other tags

I came across the issue of making set of div tags’ onClick event to be connected with a remote function, yet I couldn’t find a helper method to that and I made a simple and stupid helper method by cannibalizing link_to_remote and link_to_function helper methods.

usage: just like using link_to_remote, yet we don’t specify “name”, since there’s no text going inside the tag except the onclick event info

//e.g:
<<%= onclick_to_remote :url => my_restful_url %>; class="my_1">;

I works for me and get the work done.. arguments such as :with are supported.. Posting it here hoping someone will find it useful or may be improve it as well.
check out the pastie for better viewing pleasure and understanding http://pastie.caboo.se/200546

def onclick_to_remote(options = {})
*args = remote_function(options)
function = args[0] || ''
function = update_page(&amp;block) if block_given?
"onclick=\"#{function}; return false;\""
end

Posted in AJAX, Featured, Ruby / RailsComments (8)

Evil Facebook Apps: Your identity belongs to us..

according to BBC research, people can steal your identity through facebook and screw up your life… My guess is, only if you got such a life to be kept in secrecy.. What if your posted details are completely inaccurate, now who’s laughing :)

http://news.bbc.co.uk/1/hi/technology/7376738.stm

Posted in InternetComments (0)