Tessa Lau wrote:
Instead I’m trying to use rails to generate the checkbox
for me, but I’m still getting the “this.callback is not a function”
error in my Javascript console:
<%= check_box_tag(“private_check”, :value => “1”,
:checked => true) %>Private
<%= observe_field ‘private_check’,
:frequency => 0,
You don’t need the :frequency option. The observer will fire when the
check
box changes state. I’d get rid of it.
:update => "private_span",
:url => {:action => 'mark_private', :only_path => false},
Is there some reason you’re setting :only_path to give you the fully
qualified path? It’s probably not the problem. Just wondered what
situation is driving it’s use.
:with => "'p=' + escape(value)" %>
The purpose of the :with option in the case of observe_field is simply
to
provide the name for the key in the params hash the value in the field
will
be passed with. So if, in your controller action, you want to say
something
like:
this_item = params[:p]
then in your observe_field you’d use
:with => ‘p’
You can, of course, use a more descriptive key.
Any ideas what I’m doing wrong?
My first guess would be that something about the syntax, maybe the order
of
your parameters, could be causing the problem. I’ve never had the error
you’re getting but the documentation says:
Required options are either of:
:url: url_for-style options for the action to call when the field
has
changed.
:function: Instead of making a remote call to a URL, you can
specify a
function to be called instead.
The error you’re getting say’s Rails thinks you’re trying to tell it to
call
a function. I always put the url: => {} right after the field I’m
watching.
It’s a required field. The other stuff like :frequency and :with is
optional.
Does the observe_field only work with real form elements
and not ones created using the _tag methods?
I use it with the _tag methods.
hth,
Bill