Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorsuthern
    • CommentTimeMay 7th 2008
     
    I've seen a few posts on here from people who have some working ajax code. Would you care to share it with us? Things like the view code, controller code, and any tips/hints that you had to do to get it working would be appreciated. Thanks!
    • CommentAuthorhpatoio
    • CommentTimeMay 9th 2008
     

    In the View

    <div id="ajaxResult"></div> <h5>Add</h5> <%= form_remote_tag :url => { :action => :add_field }, :update => "ajaxResult" %> <%= text_field :myModel, :name %> <%= submit_tag %> <%= end_form_tag %>

    When you push the submit Akelos call the method "add_field" in the controller.

    add_field looks like

    function add_field() { $this->fromAjax = $this->params['topic_field']; $this->renderPartial("ajaxPartial.tpl"); }

    the file "_ajaxPartial.tpl" looks like

    This from Ajax <b>{fromAjax?}</b>

    Remember

    <%= javascript_include_tag 'prototype' %>

    in the layout

    -- Simone

Add your comments
    Username Password
  • Format comments as