Hi Ignacio,

I extracted the failing code and put it into github.  Check

[email protected]:dziesig/demo_ajax_button_problem.git

The code is partially completed, I got to this point when I hit the problem. Open the agenda, the show page illustrates the problem. Click on any one of the Up Arrow buttons (except the top one), the behaviour is correct. Click it again and see the problem. The Down Arrow buttons have a slightly different problem of their own, but I think once I get the Up working properly the Down will follow quickly.

The files up.html.erb and down.html.erb are there only because I got "template missing" errors on the second button click without them.

Meanwhile, I am going to try to figure out why the second and later button clicks show as HTML rather than JS.

Thanks,

Don

P.S. In the source application, I ran into the failure in rendering partials from dryml on the second try that I described a long while ago. The somewhat convoluted code in this demo is part of my attempt to work around that issue.





On 09/25/2014 05:28 PM, Ignacio Huerta wrote:
Sorry Don, I could not follow your example :S. It's indeed a weird bug. I suggest:

* If you want to use Dryml and Ajax updates, it might be better to use the <div part="something">...<a updates="#something"... syntax * For updates with Jquery and Rails style, it might work easier a small partial in ERB/Haml * Still, it would be interesting to reproduce your issue, so if you can provide some dummy code to reproduce, I'll be glad to play around

Warm regards,
Ignacio

On Thu, Sep 25, 2014 at 10:35 PM, Donald Ziesig <[email protected] <mailto:[email protected]>> wrote:

    Hi Ignacio!

    The html_safe almost works.  (I tried that but put it in the wrong
    place :-[ ).

    Now the only problem is much stranger.

    When I click the button once, it generates a JS response and the
    page renders correctly with appropriate data changes. The second
    and all subsequejt times I click it generates an HTML response and
    the page renders without the data outside the <def> and with no
    styling.  The data that is displayed is correct, it just looks
    funny =-O .  I did have to add an html template to get this far,
    without it I just get a missing template exception.  I didn't
    think I would have needed the html and I would really like to get
    the buttons to always generate JS like the first time.

    It must have something to do with context because the html for the
    button stays the same in firebug, it just works without ajax on
    all clicks but the first.

    Any Ideas?

    Don


    On 09/25/2014 12:06 PM, Ignacio Huerta wrote:

        Hi Don,

        Your HTML is being escaped. You need something like this:

        $('#agenda_items').html('<%=j render(:partial =>
        'agendas/table_plus',
        :locals => { :this => @this }).html_safe %>');

        You can also use "raw(html_string)" I think.

        Please say if this doesn't help :)

        Regards,
        Ignacio

        El 25/09/14 a las #4, Donald Ziesig escribió:

            Another strange one:

I am trying to render a partial (dryml) from javascript. The javascript
            is a one-liner:

            $('#agenda_items').html('<%=j render :partial =>
            'agendas/table_plus',
            :locals => { :this => @this } %>');

            The partial is also rather trivial:

                 <table-plus with="&this.agenda_items"
            fields="position, this">
            <controls:><controls-with-up-dn/></controls:>
                 </table-plus>

            Unfortunately, in the <div id="agenda_items" > ... </div>

            Instead of the table-plus and all its entries being
            rendered, the html
            (correct as near as I can tell) is rendered as text:

            <div class="table-plus"><div class="header"><div
            class="search"> <form
            action="" class="search-form" method="get"><div
            class="hidden-fields"></div> <span
            class="label">Search</span> <input
            class="search" name="search" type="search"><input
            class="button
            submit-button search-button search-submit" type="submit"
            value="Go"></form> </div></div> <table> <thead><tr
            class="field-heading-row"> <th class="position-heading"> <a
            class="column-sort position-heading-link"
            href="/agenda_items/4-approval-of-last-month-s-minutes/ ****

            The code in the partial renders correctly when invoked
            directly.

            What am I missing?

            Thanks,

            Don Ziesig


-- You received this message because you are subscribed to the Google
    Groups "Hobo Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:hobousers%[email protected]>.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    Visit this group at http://groups.google.com/group/hobousers.
    For more options, visit https://groups.google.com/d/optout.




--
Ignacio Huerta Arteche
http://www.ihuerta.net
0034 645 70 77 35
--
You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to