One thing missing from the Prototype Framework Class object is the ability to observe and fire events. Even though classes do not allow one to observe an event on the class itself, there are still a couple of ways to handle observing and firing events within a class.
Read more on Proto.Observable – Prototype Class Event Handling Mix-in…
After some researching, I’ve extended the Form.Element.Methods with a copyToClipboard method. An example of usage: $('myinput').copyToClipboard();.
A few quick notes about the clipboard and browsers.
Natively in IE5+, you can gain access to the clipboard via the window.clipboardData object. If you wanted to gain access to the clipboard in Firefox, you have to enable security preferences in your user preferences. I couldn’t find a native solution for Opera or Safari. As a result of Firefox, Opera and Safari not having direct access to the clipboard, Flash presents us with an opportunity to gain access.
Read more on Extending Prototype – Copy to Clipboard…
A question came up in #prototype today, “How can I observe a state change (checked – on/not-checked – off) on a checkbox when the state is changed by the user (mouse click) or programmatically?”. Simple right? Just observe the change event on the checkbox and that should fire every time the value property changes. Only if it was that simple!
Read more on Observing a checkbox state change…
I’ve asked this same question myself, but today I am finally taking the time to write about it.
Normally, people might think “I need to find out the x,y where the user clicked and see if that’s within the area of my element”. The answer is much easier than that.
Read more on Detect when a click is “outside” of an element…