On Viernes, 15 de Mayo de 2009 22:48:32 Soren escribió:
> Turns out that if you have destroy.rjs and on_create.rjs and you
> upgrade to rails2.3 then the on_create action dies after you click
> submit. The records are created etc etc, but the AJAX cleanup never
> happens.
>
> So I tried to copy both to their Rails 2.3 names of on_create.js.rjs
> and destroy.js.rjs and then things work fine.

In rails 2.3 you can use both extensions (rjs and js.rjs), but render :super 
only works with js.rjs

>
> So for an environment in transitions create both sets (or link them to
> each other) and don't worry about those.
>
> /S
>
> On May 13, 12:28 pm, Kenny Ortmann <[email protected]> wrote:
> > The rjs files in active scaffold are all very straight forward, if you
> > look at them you should be able to understand that they are doing.
> > They are mainly just in control of updating the page after an action, for
> > instance, the on_create.js.rjs will replace replace the create form with
> > a new one if the form had errors, or will add the record to the list if
> > the form was submitted correctly.
> >
> > When you have an embedded scaffold AS looks for method overrides in the
> > Parent controllers helper.  When you create or update or what not from
> > the embedded scaffold it actually hits the controller that the scaffold
> > is for.
> >
> > You could remove the logic for your instance variables from the views and
> > make them helper methods, or you could assign them in the controllers
> >
> > On Wed, May 13, 2009 at 2:22 PM, Soren <[email protected]> wrote:
> > > Aha!
> > >
> > > the log had the clue - it says:
> > > Rendering student/destroy.rjs
> > >
> > > The page that I need updated belongs to the forms controller, and has
> > > a student and a user embedded scaffold on it.
> > > So it makes sense that the on_create.rjs and destroy.rjs actions
> > > belong to the student view given that this was the AS that I updated
> > > to cause the action.
> > >
> > > So now the on_create.rjs and destry.rjs gets called - the first
> > > problem was instance variables - which controller does this belong to
> > > when they get activated. No obvious solution so I replaced the
> > > instance variable with some code instead. Now that part works. Can
> > > instance variables not be used, and if they can - which is the
> > > corresponding controller method ?
> > >
> > > So when you have multiple embedded scaffolds on one page then you can
> > > tie in to the javascript actions of all the AS' on that page. All you
> > > need to do is to place override methods in the various views
> > > corresponding to the embedded AS's. So in my case drop in
> > > on_create.rjs and destroy.rjs in the student view.
> > >
> > > Shall I contribute a WIKI page to the github on this ?
> > >
> > > And if so - can you please send me a very brief description of what
> > > each of the RJS's in vendor/plugins/active_scaffold/lib/
> > > active_scaffold/actions does ?
> > >
> > > /S
> > >
> > > On May 13, 10:59 am, Soren <[email protected]> wrote:
> > > > Thanks for the update.
> > > >
> > > > Copied my on_create.rjs to destroy.rjs in the same view.
> > > >
> > > > When I create a new student Firebug/net (all) shows:
> > > > GET new?_method=get&..........
> > > > GET close.gif
> > > > POST create?eid????
> > > >
> > > > When I destroy a student Firebug/net (all) shows:
> > > > POST 107?_method=delete&......
> > > > GET update_table?.......
> > > >
> > > > But no sign of on_create.rjs nor destroy.rjs
> > > >
> > > > The log shows that for destroy the destroy.rjs is rendered
> > > > but it does not show that the on_create.rjs is rendered
> > > >
> > > > /S
> > > >
> > > > On May 12, 11:57 pm, "Sergio Cambra .:: entreCables S.L. ::."
> > > >
> > > > <[email protected]> wrote:
> > > > > El Wednesday 13 May 2009 00:24:16 Soren escribió:
> > > > > > Sergio,
> > > > > >
> > > > > > Thanks for the answer. Finally had some time to play with this.
> > > > > >
> > > > > > So first of all - I know nothing about how AS works under the
> > > > > > hood - so forgive me if I ask dumb questions.
> > > > > >
> > > > > > The index page of the controller in question is the one where all
> > > > > > the fun is located. So it has two embedded AS's - one for user
> > > > > > and one
> > >
> > > for
> > >
> > > > > > students. Further down the page it has two dynamic sections - I
> > > > > > call them section3 and section4.
> > > > > >
> > > > > > If the user has created any students then the section3 needs to
> > > > > > be updated. And if they have completed section3 then section4 get
> > > > > > enabled.
> > > > > >
> > > > > > I tried to add app/views/<controller>/on_create.rjs (I use rails
> > > > > > 2.2) In that file I have:
> > > > > > page << render(:super)
> > > > > > page.replace_html "section3", :partial => "section3"
> > > > > > page.replace_html "section4", :partial => "section4"
> > > > > >
> > > > > > On the index page the two sections are properly identified with
> > > > > > <div id=section3> ... </div> etc. The index page further has a
> > > > > > render :partial for both to ensure that it loads in a proper way.
> > > > > > I notice that the on_create gets called when the there is a
> > > > > > create action in the AS, but section3 and section4 are never
> > > > > > updated. Do I need to do something different here.
> > > > >
> > > > > Check your on_create.rjs is rendered. Look at network tab in
> > > > > firebug to
> > >
> > > get the
> > >
> > > > > response, or look for "Rendering <controller>/on_create" in
> > >
> > > development.log
> > >
> > > > > > What other actions can I support? Anything that catches a
> > > > > > destroy?
> > > > >
> > > > > You can see actions code in
> > > > > vendor/plugins/active_scaffold/lib/active_scaffold/actions to guess
> > >
> > > which files
> > >
> > > > > are rendered in each action. For destroy, the view is destroy.rjs
> > > > >
> > > > > > /S
> > > > > >
> > > > > > On Apr 27, 2:28 am, "Sergio Cambra .:: entreCables S.L. ::."
> > > > > >
> > > > > > <[email protected]> wrote:
> > > > > > > El Saturday 25 April 2009 23:27:49 Soren escribió:
> > > > > > > > I have a page upon which I have to embedded scaffolds.
> > > > > > > >
> > > > > > > > At some point the user might have created data with those
> > >
> > > scaffolds
> > >
> > > > > > > > such that additional options to the page should be enabled.
> > > > > > > >
> > > > > > > > Any suggestions to cause the page to get reloaded after an
> > > > > > > > CRUD
> > >
> > > action
> > >
> > > > > > > > on one of the scaffold (simplest solution) or how to cause an
> > >
> > > AJAX
> > >
> > > > > > > > action to trigger that would update the page with the new
> > >
> > > options.
> > >
> > > > > > > > Is the before_create_save action in AS a path
> > >
> > > anyonehassuccessfully
> > >
> > > > > > > > used for this ?
> > > > > > > >
> > > > > > > > /S
> > > > > > >
> > > > > > > You should add some javascript to the views to reload the
> > > > > > > scaffold,
> > >
> > > or
> > >
> > > > > > > add a new link with javascript after a create for example. Try
> > > > > > > to
> > >
> > > create
> > >
> > > > > > > a on_create.js.rjs view (in rails 2.3, on_create.rjs in
> > > > > > > previous versions) in your controller's views, call render
> > > > > > > :super to include
> > >
> > > the
> > >
> > > > > > > default response and add your javascript code.
> > > > > > >
> > > > > > > For example:
> > > > > > > page << render(:super)
> > > > > > > page.insert_html :top, active_scaffold_tbody_id, 'html code'
> > > > > > > page.insert_html :top, active_scaffold_tbody_id, :partial =>
> > > > > > > 'partial_name' page << 'custom JS code'
> > > > > > >
> > > > > > > --
> > > > > > > Sergio Cambra .:: entreCables S.L. ::.
> > > > > > > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > > > > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
> > > > >
> > > > > --
> > > > > Sergio Cambra .:: entreCables S.L. ::.
> > > > > Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
> > > > > T) 902 021 404 F) 976 52 98 07 E) [email protected]
>
> 
-- 
Sergio Cambra .:: entreCables S.L. ::.
Nicolás Guillén 6, locales 2 y 3. 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to