The Hitchhiker’s Guide to Ruby On Rails Galaxy

Records of my voyage through RoR Galaxy

Posts Tagged ‘javascript’

To make text in TextArea selectable onclick of mouse

Posted by arjunghosh on April 28, 2008

I am very sure most know about this and is a very simple thing. But as I have found sometimes that small things are the one which are missed.

So wanted a quick note on – How to make the text inside a textarea selectable on mouse click.

Well, we use the Javascript event system
[def: An event in Javascript is something that happens with or on the web page ].

Specifically we use the onclick Event to achieve the above stated goal. onClick applies to buttons (submit, reset, and button), checkboxes, radio buttons, and form upload buttons.

This is how we do it:

<textarea rows="3" cols="43" name="none" onclick=";">This is the text which when clicked on will get selected</textarea>

The main syntactic sugar here is the “onclick=”;”

Here the “this” helps us to access the textarea object and then we fire the DOM event “select()”
dynamically on it, which in turns selects the text inside the textarea.
ciao until next time 🙂


Posted in Uncategorized | Tagged: , , , , | 6 Comments »

:disable_with does not work with Merb

Posted by arjunghosh on February 14, 2008

Beside the known problem of :disable_with killing form_remote_tag AJAXiness, I recently faced another one – namely that it seem :disable_with for Submit_tag does not play well with Merb . In the current project I am working, we decided to use Merb for file upload as it is a very fast and lightweight server which was originally built for efficient file uploads. Well, I thought of using the :disable_with option in submit_tag for some fancy submit button state to indicate that the current form is submitting. Well at the first look everything seem fine, and the form got submit. Then after more testing, we found that picture upload in that form via Merb was not working. After some hectic debugging(as :disable_with is the an obvious suspect), we concluded that :disable_with was the culprit. Well the solution to this was a crude hack where we are calling a javascript in the :onsubmit to accessing the submit button and changing the style while the form gets submitted. Well thats what I can think of in short notice. If anyone has a solution for this, please feel free to tell.

Posted in Uncategorized | Tagged: , , , , | Leave a Comment »