in_place_editor_field fun! Possible to pass more parameters?

Hey guys...

I'm wondering if there is way to submit extra parameters with

<%= in_place_editor_field :model, :attribute %>

For example, if I wanted to submit the current time or something like
that to run through my own custom set_model_attribute method that is
called when the editor is saved.

Thanks in advance

p.s. sorry if this is a double post, I think my first attempt failed.

Hey guys…

I’m wondering if there is way to submit extra parameters with

<%= in_place_editor_field :model, :attribute %>

For example, if I wanted to submit the current time or something like

that to run through my own custom set_model_attribute method that is
called when the editor is saved.

The :with option is used to construct the parameter string to return

:with:JavaScript snippet that should return what is to be sent in the AJAX call,
form is an implicit parameter

So you need to have a string that will eval to Javascript on the client side.

Hope that’s what your after :slight_smile:

I'm pretty sure that is what I'm after, and I tried using that 100
times, maybe I'm just useless.

How would I go about passing a string using the "with" command?

My javascript.fu
is not strong. It’s my understanding that you need to construct the parameters for the url in javascript. I’m sure there are nicer ways of doing this.


:with => “‘param_name=’ + $(‘dom_id’).value + ‘&param_2_name=’ + some_js_function_that_returns_an_encoded_string()”

I believe something like that. I think there are things in prototype.js to assist with this. Serialize on forms may help.
You need a string within a string. The above starts with a " for rubys sake, then immediately has a single ’ for js. Anything in the single will be a literal for js, and anything just in the double " will be executed in js as a function.

I'll check it out. Thanks for your help.

Although I guarantee my "javascript.fu" is worse than yours.

Found a solution,

for Archieval purposes... just use RJS files, here's a cool walk
through;

http://www.shanesbrain.net/articles/2006/01/19/in-place-editor-with-rjs-templates

It's 100 times easier.

That is much nicer. Thanx for linking