Re: in_place_editor_field

Me again,
Right - I've done a little digging setting certain variables for this but unfortunatly with no working solution yet.

So firstly I found we can set the highlight colour using various javascript options (source: http://wiki.script.aculo.us/scriptaculo … aceEditor)

Then I looked up the helper (source: http://dev.rubyonrails.org/svn/rails/tr … helper.rb) which appears not to support changing the highlight colours.

So at the moment I've just re-created manually without the helper (in_place_editor_field)

A

Re: in_place_editor_field

For those interested:

        <span class="in_place_editor_field" highlight_color="#000" id="task_list_title_<%= tasklist.id %>_in_place_editor"><%= tasklist.title %></span><script type="text/javascript">
        //<![CDATA[
        new Ajax.InPlaceEditor('task_list_title_<%= tasklist.id %>_in_place_editor', '/tasks/set_task_list_title/<%= tasklist.id %>', {
                    highlightcolor:'#1e7db9',
                    highlightendcolor:'#1e7db9',
                    onComplete: function(transport, element) {new Effect.Highlight(element, {startcolor: '#14699f', endcolor:'#1e7db9'});}
                });
        //]]>
        </script>

Thats what I used in the view file - I'll move it over to its own partial to keep things tidy in the templates. Can you create your own HTML helpers available for all templates? Like allowing that code above to be sent the browser if you just provide certain details?

Last edited by shadow (2006-09-04 18:00:57)

Re: in_place_editor_field

you can put html into the normal helper methods, the only problem is that it needs to be quoted to print the html out...

module WhateverHelper
 
  def say_hello
    '<div id="bob">Hello</div>'
  end
 
end

then in your view, you can just use

<%= say_hello %>

without the quotes around the html, it would be evaluated as ruby code and so would cause an error. With your html using both single and double quotes, this is going to cause issues.

To get around this, you can either escape the quotes in the html or you can make a string by using %Q{string}..

module WhateverHelper
 
  def say_hello
    %Q{<div id="bob">Hello</div>}
  end
 
end

If you put it in your application_helper.rb, it'll be available to every view.

Last edited by idlefingers (2006-09-04 19:27:29)

Re: in_place_editor_field

Thanks for that - how would you go about sending variables to the helper which can then be included in the output?

I thought you could use def say_hello(variable1, variable2) but then I don't know how to include these values in the helper itself.

Re: in_place_editor_field

yeah, use the brackets to feed arguments in, and then you can use #{variable1} in the string to bring their values in.

Re: in_place_editor_field

Your discussion about the in_place_editor_field was very helpful. But now what is the point of these fields if you can't validate or edit empty fields? Users now can leave fields empty or fill them with meaningless text. So in the end I write my own actions for every in_place_edit_field?

The rails recipes book has a simple solution and says just to just default values like "click to edit". How could you implement this and is there a way to validate?

thnx