Thank you very much, that's an awesome idea, as I'm not very proficient
(yet) in ajax myself.



On Fri, Oct 23, 2015 at 9:02 AM, Sergio Cambra <[email protected]>
wrote:

> On page load ActiveScaffold call this methods:
>
> ActiveScaffold.load_embedded(document);
> ActiveScaffold.enable_js_form_buttons(document);
> ActiveScaffold.live_search(document);
> ActiveScaffold.auto_paginate(document);
> ActiveScaffold.draggable_lists('.draggable-lists', document);
>
>
> Also, ActiveScaffold adds a listener for as:element_updated event, and call
> this methods there:
>     ActiveScaffold.load_embedded(e.target);
>     ActiveScaffold.enable_js_form_buttons(e.target);
>     ActiveScaffold.live_search(e.target);
>     ActiveScaffold.draggable_lists('.draggable-lists', e.target);
>
> So you could add a listener to your menu links, to trigger that event when
> success:
>
> $(document).on('ajax:success', 'selector for menu link', function() {
>   $(document).trigger('as:element_updated);
> });
>
> El Viernes, 23 de octubre de 2015 08:54:33 Cláudio Forain escribió:
> > Yes, it fails. But if I open on another tab, it renders the AS table, but
> > with broken CSS.
> >
> > Anyway, as it turns out, the bootstrap drop_down makes an ajax request to
> > the page, which seems to prevent events like page onload from being
> > triggered.
> > So, I started to look arround, and found this on
> > active_scaffold-3.4.29/app/assets/javascripts/jquery/active_scaffold.js :
> >
> > /* setup some elements on page/form load */
> >   ActiveScaffold.load_embedded(document);
> >
> > (awesome code and commen, btw)
> >
> > So, I tried to load it manually on my view:
> >
> > $(function(){
> >   ActiveScaffold.load_embedded(document);
> > });
> >
> > And it worked! If this is too inelegant, I accept suggestions. Thanks
> once
> > again.
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Oct 22, 2015 at 2:46 PM, Cláudio Forain <[email protected]
> >
> >
> > wrote:
> > > Just a new piece of information. The problem seems to be with the menu
> I'm
> > > using to link the page in my application layout. If I paste the url
> > > directly on the address bar (http://myapp/reports/work_hours), it
> works
> > >
> > > as expected. Here is the relevant menu:
> > >             <%= drop_down "Relatórios" do %>
> > >
> > >                 <%= menu_item "Horas Trabalhadas",
> '/reports/work_hours'
> > >                 %>
> > >
> > >             <% end %>
> > >
> > > Am I missing some parameter that needs to be passed? Thanks again.
> > >
> > >
> > >
> > >
> > > On Thu, Oct 22, 2015 at 2:33 PM, Cláudio Forain <
> [email protected]>
> > >
> > > wrote:
> > >> I think we are getting to the problem. There is absolutely no errors
> in
> > >> the page at all, only some bootstrap css warnings. Anyway, inspecting
> the
> > >> network console, I noticed that when I hit the page for the first time
> > >> (when it doesn't work), I get this request:
> > >>
> > >> http://myapp/reports/work_hours
> > >>
> > >> But when I refresh it (when it does work), I get both these requests:
> > >>
> > >> http://myapp/reports/work_hours
> > >>
> > >>
> > >>
> http://myapp/work_hours_configs?eid=0f726c1c7c83871405ff3781a71db031&embe
> > >> dded=true
> > >>
> > >>
> > >> I would just like to point out that there is no js errors on console
> > >> whatsoever. Any tips on why is the second request being ommited on the
> > >> first hit? Thanks a lot.
> > >>
> > >>
> > >>
> > >>
> > >> On Thu, Oct 22, 2015 at 5:41 AM, Sergio Cambra <
> [email protected]>
> > >>
> > >> wrote:
> > >>> When page is loaded, some JS should call server to replace link with
> > >>> embedded
> > >>> scaffold.
> > >>>
> > >>> Look console for JS errors
> > >>> Also look network tab on web inspector, check if request for your
> > >>> embedded
> > >>> scaffold is issued
> > >>>
> > >>> El Miércoles, 21 de octubre de 2015 19:14:37 Cláudio Forain escribió:
> > >>> > Hello. I'm using activescaffold-3.4.29, rails 4.2.0 and ruby 2.2.0.
> > >>> > So, I have a view that essentialy is an embedded AS list followed
> by
> > >>> > an
> > >>> > html table.
> > >>> >
> > >>> > view.html.erb
> > >>> >
> > >>> >   <%= render  :active_scaffold => work_hours_configs"%>
> > >>> >
> > >>> > my html table
> > >>> >
> > >>> > The problem is when I first make the request for the page, the
> > >>> > embedded
> > >>> > scaffold is simply "closed", and it has a link with the name of my
> > >>>
> > >>> entity
> > >>>
> > >>> > (WorkHoursConfigs) that does nothing:
> > >>> >
> > >>> > http://postimg.org/image/vnyt7vwxv/
> > >>>
> > >>> > And the link points to this url:
> > >>>
> http://my_app/work_hours_configs?eid=0f726c1c7c83871405ff3781a71db031&em
> > >>> bedd>>>
> > >>> > ed=true
> > >>> >
> > >>> > Here is the generated html of the link:
> > >>> >
> > >>> > <a class="load-embedded" data-remote="true"
> > >>>
> > >>>
> href="/work_hours_configs?eid=0f726c1c7c83871405ff3781a71db031&amp;embed
> > >>> ded=>>>
> > >>> > true">WorkHoursConfigs</a>
> > >>> >
> > >>> > But if I refresh that page, everything seems to go as expected:
> > >>> >
> > >>> > http://postimg.org/image/ardkj06hj/
> > >>> >
> > >>> >
> > >>> > I tried to look at the documentation to see if there is any
> > >>>
> > >>> configuration
> > >>>
> > >>> > to make the embedded scaffold to be already opened, to no avail.
> Any
> > >>>
> > >>> tips?
> > >>>
> > >>> > Thanks in advance.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/activescaffold.
For more options, visit https://groups.google.com/d/optout.

Reply via email to