ajax html callback

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ajax html callback

mmimica
Hi!

I've got a div that I want to re-render using an AJAX callback. The rendering of
this div is isolated in a helper method:

MyWAComopnent >> renderDivOn: html
| id |
        html div id: (id := html nextId); with: [ html render: content ].
        html ... (html jQuery id: id) load html: [ :h | self renderDivOn: h ].

The above does not work as expected because the AJAX actually replaces the
*contents* of the queried DOM element, leaving you with an additional nested div
tag on each rendering.

Is there an easy fix to this, other than moving the rendering of the div tag to
the outer level?


--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

Johan Brichau-2

On 27 Apr 2011, at 22:25, Milan Mimica wrote:

> Is there an easy fix to this, other than moving the rendering of the div tag to the outer level?

How much easier do you want it to be? That sounds like the most reasonable approach (I'm applying that pattern *a lot*).
An alternative approach is to use the replace of jQuery in an ajax script callback:

(html jQuery ajax) script: [:s | s << ((s jQuery id: id) replaceWith: [:r | self renderDivOn: r])]

Johan_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

Robert Sirois
In reply to this post by mmimica
Try it without load? You could drop it in an ajax script then.

RS

Milan Mimica <[hidden email]> wrote:

>Hi!
>
>I've got a div that I want to re-render using an AJAX callback. The rendering of
>this div is isolated in a helper method:
>
>MyWAComopnent >> renderDivOn: html
>| id |
> html div id: (id := html nextId); with: [ html render: content ].
> html ... (html jQuery id: id) load html: [ :h | self renderDivOn: h ].
>
>The above does not work as expected because the AJAX actually replaces the
>*contents* of the queried DOM element, leaving you with an additional nested div
>tag on each rendering.
>
>Is there an easy fix to this, other than moving the rendering of the div tag to
>the outer level?
>
>
>--
>Milan Mimica
>http://sparklet.sf.net
>_______________________________________________
>seaside mailing list
>[hidden email]
>http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

sebastianconcept@gmail.co
In reply to this post by mmimica
you need to do an update (check updater examples)



On Apr 27, 2011, at 5:25 PM, Milan Mimica wrote:

> Hi!
>
> I've got a div that I want to re-render using an AJAX callback. The rendering of
> this div is isolated in a helper method:
>
> MyWAComopnent >> renderDivOn: html
> | id |
> html div id: (id := html nextId); with: [ html render: content ].
> html ... (html jQuery id: id) load html: [ :h | self renderDivOn: h ].
>
> The above does not work as expected because the AJAX actually replaces the *contents* of the queried DOM element, leaving you with an additional nested div tag on each rendering.
>
> Is there an easy fix to this, other than moving the rendering of the div tag to the outer level?
>
>
> --
> Milan Mimica
> http://sparklet.sf.net
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

mmimica
In reply to this post by Johan Brichau-2
Johan Brichau wrote:
> On 27 Apr 2011, at 22:25, Milan Mimica wrote:
>
>> Is there an easy fix to this, other than moving the rendering of the div tag to the outer level?
>
> How much easier do you want it to be? That sounds like the most reasonable approach (I'm applying that pattern *a lot*).

It may be a valid pattern but I don't like it. Having the rendering of the div
tag and its contents at the same place looks better to me. Although I've never
done a WEB page before.



--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

Julian Fitzell-2
Write a javascript function to pull the *contents* out of the returned
element and use that for the replacement...? I agree it's not a nice
pattern to have to keep pulling out that one tag from every method.

Julian

On Thu, Apr 28, 2011 at 7:00 PM, Milan Mimica <[hidden email]> wrote:

> Johan Brichau wrote:
>>
>> On 27 Apr 2011, at 22:25, Milan Mimica wrote:
>>
>>> Is there an easy fix to this, other than moving the rendering of the div
>>> tag to the outer level?
>>
>> How much easier do you want it to be? That sounds like the most reasonable
>> approach (I'm applying that pattern *a lot*).
>
> It may be a valid pattern but I don't like it. Having the rendering of the
> div tag and its contents at the same place looks better to me. Although I've
> never done a WEB page before.
>
>
>
> --
> Milan Mimica
> http://sparklet.sf.net
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

Johan Brichau-2
You don't need to. The easiest solution is to use a script callback that does a jQuery>>replaceWith: (see my previous response)

But what is not nice about the following?

renderContentOn: html
...
html div
        id: #basket;
        with: [ self renderBasketContentsOn: html].
...

and have somewhere: (html jQuery id: #basket) load html: [:r | self renderBasketContentsOn: r]

imho, this only splits up the rendering methods in conceptual parts

Johan
On 02 May 2011, at 15:40, Julian Fitzell wrote:

> Write a javascript function to pull the *contents* out of the returned
> element and use that for the replacement...? I agree it's not a nice
> pattern to have to keep pulling out that one tag from every method.
>
> Julian
>
> On Thu, Apr 28, 2011 at 7:00 PM, Milan Mimica <[hidden email]> wrote:
>> Johan Brichau wrote:
>>>
>>> On 27 Apr 2011, at 22:25, Milan Mimica wrote:
>>>
>>>> Is there an easy fix to this, other than moving the rendering of the div
>>>> tag to the outer level?
>>>
>>> How much easier do you want it to be? That sounds like the most reasonable
>>> approach (I'm applying that pattern *a lot*).
>>
>> It may be a valid pattern but I don't like it. Having the rendering of the
>> div tag and its contents at the same place looks better to me. Although I've
>> never done a WEB page before.
>>
>>
>>
>> --
>> Milan Mimica
>> http://sparklet.sf.net
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ajax html callback

mmimica
On 2 May 2011 16:10, Johan Brichau <[hidden email]> wrote:
> You don't need to. The easiest solution is to use a script callback that does a jQuery>>replaceWith: (see my previous response)

I saw that. Not a nice solution either, you'll probably agree.

> But what is not nice about the following?
>
> renderContentOn: html
> ...
> html div
>        id: #basket;
>        with: [ self renderBasketContentsOn: html].
> ...
>
> and have somewhere: (html jQuery id: #basket) load html: [:r | self renderBasketContentsOn: r]
>
> imho, this only splits up the rendering methods in conceptual parts

Okay, it just something that I'll have to get used to.


--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside