How to update more than one div through form_remote_tag


#1

Hi All
I have to update more than a single DIV through form_remote_tag .
I am posting my code .
In rhtml page

<%= form_remote_tag({:url=>{:controller=>‘image_builders’, :action
=>‘image_creation’}, :update =>‘photo’,
:html=>{:onsubmit=>‘UrlGeneration(this)’}})%>


Type


Slash
Strip
Dot
Gradation

Margin

px
      <dt>Line Color</dt>
      <dd>
      <div style="margin-bottom:5px"><input name="linetrans"

id=“linetrans” type=“checkbox” onClick=“showHideBox(this,‘line’)” />
Transparent



Line Color:
<%= text_field_tag ‘linecolor’, ‘#000000’,
:onfocus=>“blur()”%>
 

      <dt>Background Color</dt>
      <dd>
      <div style="margin-bottom:5px"><input name="bgtrans"

id=“bgtrans” checked=“checked” type=“checkbox”
onClick=“showHideBox(this,‘background’)” /> Transparent



Background Color:
<%= text_field_tag ‘bgcolor’, ‘#FFFFFF’, :onfocus=>“blur()” %>
 

      <dt>Size</dt><dd>

      <input name="auto" id="auto" checked="checked" type="checkbox"

onclick=“enable_field(auto, width, height)”> Auto


width
height

Alpha



between 0(opaque)
and 127(transparent)
      </dd>
      <dt>Options</dt><dd><input name="reverse" id="reverse"

value=“1” type=“checkbox”> Reverse



<%= submit_tag ‘Create Image’ %>
  <!-- end customize -->

    </td>
    <td width="65%" valign="top" align="left">

  <!-- start preview --><h2>Preview</h2>


    <div id='result'>

      <div><label for='url'><b>URL:</b></label>
      <%= text_field_tag 'url', @url_for , :size => 75

,:onFocus=>‘this.select()’%>

      </div>
      <div>
      <label><b>Image:</b></label>
      <div id="photo" style="width:99%;">
        <img src='/images/xyz.png'/>
      </div>
      </div>

      <div>
      <label><b>Sample Area:</b></label>

      <div class="prv" id="photo" >

        <div id="sample1" style="width:200px; height:200px;

margin-left:5px; background:url(’’) repeat top left;">

Sample






    </div>
  <!-- end preview -->

=============================================================================

As i am updating “photo” here , I have to refresh the other div’s like
Sample1,
Sample2,Sample3,Sample4 also

Code in my controller

# Creation of Gradition Image
if params[:id] == 'gradation'
  if params[:linetrans]
    @line_color = "#000000"
  end
  if params[:bgtrans]
    @bg_color = "#FFFFFF"
  end
  fill = Magick::GradientFill.new(0, 0, 0, @Width, @line_color,

@bg_color)
img = Magick::Image.new(@Height, @Width, fill)
img.opacity = @alpha/ 127.0 * Magick::TransparentOpacity if
@alpha != 0
img_new = img.rotate(90)
if params[:reverse]
img_rev = img_new.rotate(270)
img_rev.write(“public/images/bgmaker/gradation/xyz.png”)
render :text => “”
else
img_new.write(“public/images/bgmaker/gradation/xyz.png”)
render :text => “”
end
end

If anybody having any solution please let me know , it would be great
help for me .

Thanks In Advance


#2

On Jan 21, 2009, at 8:26 AM, Kumar S. wrote:

=

=

<%= form_remote_tag({:url=>{:controller=>‘image_builders’, :action
=>‘image_creation’}, :update =>‘photo’,
:html=>{:onsubmit=>‘UrlGeneration(this)’}})%>

First, you don’t want to pass an :update option to form_remote_tag.
Then you want to start reading about update_page here:

http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001436

Basically you’ll return some javascript which will do whatever you
want… updating divs, hiding stuff, replacing other stuff, etc…

-philip