Hi there,
I'm really enjoying the Ajax integration with Seaside. Thanks Lukas! I'm trying to embed a hyperlink into a third party widget (Google Maps). I want to place a link into the marker and then execute an ajax call that updates a list on the server when a user clicks on that link. I'm confused how I should implement this because I don't understand what parameters I should use for the session variables and Seaside+Scriptaculous builds the IDs and everything else for me. I assume I should define a wrapper method that then calls into a seaside generated ajax method, but since all the Ajax code is so tightly wrapped into Seaside, I'm struggling on where to do this. I love that I don't even have to think about Ajax in order to use it, but in this case I'd like to find a hook into the process. Anyone have any guidance? Chris _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> I'm really enjoying the Ajax integration with Seaside. Thanks Lukas!
Thank you. > I'm trying to embed a hyperlink into a third party widget (Google Maps). I > want to place a link into the marker and then execute an ajax call that > updates a list on the server when a user clicks on that link. I'm confused > how I should implement this because I don't understand what parameters I > should use for the session variables and Seaside+Scriptaculous builds the > IDs and everything else for me. I assume I should define a wrapper method > that then calls into a seaside generated ajax method, but since all the Ajax > code is so tightly wrapped into Seaside, I'm struggling on where to do this. > I love that I don't even have to think about Ajax in order to use it, but > in this case I'd like to find a hook into the process. I don't know how you pass this link to Google Maps? If you want to generate an URL-String for a given AJAX updater you can write something like: (html updater id: 'foo'; callback: [ :r | r render: 'bar' ]; url) asString Is this what you want? Or do you also need an XHTML snippet with an anchor tag around that? (html javascript render: [ :h1 | h1 anchor onClick: (h1 updater id: 'someId'; callback: [ :h2 | h2 render: 'Hello World' ]); with: 'Click Me' ]) asJavascript I guess you get the idea ;-) Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas,
Thanks for your assistance. I know how to put the link into Google Maps so I am covered there. What I need is basically this: a link that provides something like "javascript:addToCollection('123456');". When the user clicks on the link it makes an Ajax call and adds to a collection on the server. 123456 would be a code that I can then use to address the marker on the google map. The point is I need to build the addToCollection links on the client side in javascript, so I assume I need to generate a Seaside wrapper function which then carries the 123456 parameter into my callback. I tried to use the code you provided in one method and I get: MessageNotUnderstood: SUScript>>render: I fiddled around in the debugger, but was not sure how to resolve this. I tried using #render:on: and didn't get much better results. Am I using an out of date Scriptaculous package? Chris On Tue, Jun 3, 2008 at 11:10 PM, Lukas Renggli <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> When the user
> clicks on the link it makes an Ajax call and adds to a collection on the > server. Ok, if you don't want to update then simply use the AJAX requestor: (html request callback: [ coll add: 123 ]) asJavascript This expression gives you a string that when evaluated by the Javascript engine triggers the execution of the Smalltalk block on the server. If you need to pass some data from the JavaScript world to the server you can use something like that: (html request callback: [ :v | coll add: v ] value: (SUStream on: 'navigator.appName')) asJavascript In this case the property navigator.appName is passed to the server. As far as I understand you want to pass some Google Maps data there. > I tried to use the code you provided in one method and I get: > > MessageNotUnderstood: SUScript>>render: I write most of the examples for the mailing-list directly in the mail-application, therefore there is usually some significant amount of fixing needed before usage. I only try to clear what the general approach is. For the example in the previous mail: Remove #asJavascript, the thing is already a string. SUScript in my Seaside 2.8 images understands #render:. > tried using #render:on: and didn't get much better results. Am I using an > out of date Scriptaculous package? I don't know what platform and version you are on. Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
I'm almost there.
I have a marker on the map which houses a link with an onclick handler called 'addLocation( "123456" );'. So, I tried to define addLocation like this: html script: (' function addLocation( theId ) { ', (( html updater id: 'locations'; callback: [ :v | locations add: ( myLocation new title: v ). self renderLocationsOn: html. ] value: (SUStream on: 'theId')) asJavascript ), '; }' ). ] ] This crashes my updater. It does pass the value of theId properly as this is stored into the MyLocation collection. But, it seems I need an html object renderer passed back to me. Chris On Wed, Jun 4, 2008 at 11:24 PM, Lukas Renggli <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> I have a marker on the map which houses a link with an onclick handler
> called 'addLocation( "123456" );'. So, I tried to define addLocation like > this: > > html script: (' function addLocation( theId ) { ', (( > html updater > id: 'locations'; > callback: [ :v | > locations add: ( myLocation new title: v ). > self renderLocationsOn: html. > ] > value: (SUStream on: 'theId')) asJavascript ), '; }' > ). > ] > ] > > This crashes my updater. It does pass the value of theId properly as this > is stored into the MyLocation collection. But, it seems I need an html > object renderer passed back to me. You should not render within #callback:value:. Use a rendering-callback to update your page. Furthermore, pay attention that 'html' is not valid anymore (this html stream has been sent out when the script was generated) when the callback is triggered. Use the renderer that gets passed into the render-callback. Slime detects that kind of problems. html updater id: 'locations'; callback: [ :v | locations add: v ] value: 'something'; callback: [ :r | self renderLocationsOn: r ]. Please check out the class comments in SUAjax and subclasses. Also the methods #callback:value: and #callback: are heavily documented. Cheers, Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Lukas,
Thank you. I got it working. I will definitely read further in the documentation. Ah, coding in Seaside is like going from painting with blocks of wood to creating a Mona Lisa. Seaside code is pure art. Chris On Thu, Jun 5, 2008 at 2:05 AM, Lukas Renggli <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |