Hey
I’m new to Rails, and I was wondering if there was a way to include
custom javascript libraries in the HTML views? I’ve been searching for
a while and can’t seem to find any way to do this.
For example, I want to have some javascript function firing an onkeyup
event from an input element that is generated dynamically. It’s
nothing to do with ajax – all client side. Everything I’ve found just
deals with remote calls. I suspect it is something to do with
observe_field :function, but can’t seem to get it working.
Thanks.
On Jul 24, 7:30 pm, muckypup [email protected] wrote:
observe_field :function, but can’t seem to get it working.
Just go ahead and write the javascript as you normally would. the
helpers can be handy in some cases but don’t be afraid of ignoring
them
Fred
Ah. At first I thought I had done that, but I must have mistyped it
when I first did it. I wish I had asked earlier now, just spent quite
a while banging my head against a wall for nothing. 
Stupid :onkeyup =>.
Thanks. 
On Jul 24, 7:50 pm, Frederick C. [email protected]
I like the javascript_include_tag helper to keep the javascript out of
the view.
In one of my views I have a collection of radio buttons with class
“our_aircraft” and a text field with class “other_aircraft”. Then I
pull in some javascript:
= javascript_include_tag 'aircraft_selection'
In public/javascripts/aircraft_selection.js I clear the text field
when a radio button is checked and clear the radio buttons when the
text field receives input:
$(document).ready(function () {
$(".our_aircraft").change(function () {
$(".other_aircraft").val("");
});
$(".other_aircraft").keyup(function () {
if ($(this).val() > “”) {
$(".our_aircraft").removeAttr(“checked”);
}
});
});
Enjoy!
Bryan