a problem using javascript goto and jquery and some complex stuff

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

a problem using javascript goto and jquery and some complex stuff

EstebanLM
Hi,
I have a problem dealing with some ajax renderization... I have
something like this:

        html anchor
                onClick: (html javascript
                        goto: (html jQuery get
                                callback: [ self show: tabsComponent ];
                                fullUrl));
                with: 'goto blah'.


of course, this is not my real need, just a simplified version :)

and whenever the callback is executed, it just renders a blank page...
but if I change the #show: for #call:, the new component is rendered
correctly... I think this is not correct, because same behavior is
happening in other contexts (for example, I want to execute a callback
after render a confirmation dialog, something like this:

        | dialogId |
        dialogId := html nextId.
        self canvas div id: dialogId.
        self canvas script: (html jQuery new dialog
                id: dialogId;
                html: someComponent;
                title: 'Title;
                width: 600;
                addButton: 'Accept' do: (html javascript
                        goto: (html jQuery get
                                callback: [
                                        "This is fake code, but shows what I need :)"
                                        self doSomethingLikeRemoveARow.
                                        self refreshReport ];
                                fullUrl));
                addButton: 'Cancel' do: html jQuery new dialog close;
                resizable: false;
                modal: true
                autoOpen: true).


again, this is a simplified version of something I do for reef, but it
shows more or less what I want... and I get a blank page all the time...

Any idea how to solve this?

Cheers,
Esteban


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

Re: a problem using javascript goto and jquery and some complex stuff

Johan Brichau-2
Hi Esteban,

The goto makes your browser navigate to the url of an ajax callback. That will execute the callback server-side but the response of that callback is empty, hence the blank page. I think the use of #call: will trigger a redirect in the callback, hence why that is working (just writing this of the top of my head, did not verify). You either need to use normal callbacks, or use jQuery to add or replace the html inline on your webpage. Something along the lines of:

html anchor
                onClick: (html jQuery ajax
                                                callback:[self doSomethingLikeRemoveARow];
                                                onComplete:(html jQuery ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r | tabsComponent renderOn: r])  ]);
                with: 'goto blah'.

-or-

html anchor
                callback: [self doSomethingLikeRemoveARow. self show: tabsComponent ];
                with: 'goto blah'.

In the first case, it's important that you cancel the default behavior of the anchor because otherwise it will execute a full callback instead of an ajax request only. I'm always sending 'url: 'javascript:{}' to such an anchor to cancel the default generated Seaside url, but there are other ways.

Hope it helps
Johan

On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:

> Hi,
> I have a problem dealing with some ajax renderization... I have something like this:
>
> html anchor onClick: (html javascript goto: (html jQuery get callback: [ self show: tabsComponent ];
> fullUrl));
> with: 'goto blah'.
>
>
> of course, this is not my real need, just a simplified version :)
>
> and whenever the callback is executed, it just renders a blank page... but if I change the #show: for #call:, the new component is rendered correctly... I think this is not correct, because same behavior is happening in other contexts (for example, I want to execute a callback after render a confirmation dialog, something like this:
>
> | dialogId |
> dialogId := html nextId. self canvas div id: dialogId.
> self canvas script: (html jQuery new dialog id: dialogId;
> html: someComponent;
> title: 'Title;
> width: 600;
> addButton: 'Accept' do: (html javascript
> goto: (html jQuery get
> callback: [
> "This is fake code, but shows what I need :)"
> self doSomethingLikeRemoveARow.
> self refreshReport ];
> fullUrl));
> addButton: 'Cancel' do: html jQuery new dialog close;
> resizable: false;
> modal: true
> autoOpen: true).
>
>
> again, this is a simplified version of something I do for reef, but it shows more or less what I want... and I get a blank page all the time...
>
> Any idea how to solve this?
>
> Cheers,
> Esteban
>
>
> _______________________________________________
> 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: a problem using javascript goto and jquery and some complex stuff

EstebanLM
Hi,
What I really want is to force a page refresh, but decide when this is
necesary inside a javascript callback. For example, I open a "confirm
dialog"... y you cancel the operation, nothing happens, but if you
agree, a new page is rendered (not an ajax part, a whole new page),
this is more or less the behavior I'm needing (something like the large
example below).
btw... I tryed using "html jQuery ajax" instead "html jQuery get" (and
in fact I also tested with "post"), with exactly the same result for
this issue.

Cheers,
Esteban

On 2010-11-03 03:54:17 -0300, Johan Brichau <[hidden email]> said:

> Hi Esteban,
>
> The goto makes your browser navigate to the url of an ajax callback.
> That will execute the callback server-side but the response of that
> callback is empty, hence the blank page. I think the use of #call: will
> trigger a redirect in the callback, hence why that is working (just
> writing this of the top of my head, did not verify). You either need to
> use normal callbacks, or use jQuery to add or replace the html inline on
> your webpage. Something along the lines of:
>
> html anchor
> onClick: (html jQuery ajax
> callback:[self
> doSomethingLikeRemoveARow];
> onComplete:(html jQuery
> ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r |
> tabsComponent renderOn: r])  ]);
> with: 'goto blah'.
>
> -or-
>
> html anchor
> callback: [self doSomethingLikeRemoveARow. self show:
> tabsComponent ];
> with: 'goto blah'.
>
> In the first case, it's important that you cancel the default behavior
> of the anchor because otherwise it will execute a full callback instead
> of an ajax request only. I'm always sending 'url: 'javascript:{}' to
> such an anchor to cancel the default generated Seaside url, but there
> are other ways.
>
> Hope it helps
> Johan
>
> On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:
>
>> Hi,
>> I have a problem dealing with some ajax renderization... I have
> something like this:
>>
>> html anchor onClick: (html javascript
> goto: (html jQuery get callback: [ self show:
> tabsComponent ];
>> fullUrl));
>> with: 'goto blah'.
>>
>>
>> of course, this is not my real need, just a simplified version :)
>>
>> and whenever the callback is executed, it just renders a blank page...
> but if I change the #show: for #call:, the new component is rendered
> correctly... I think this is not correct, because same behavior is
> happening in other contexts (for example, I want to execute a callback
> after render a confirmation dialog, something like this:
>>
>> | dialogId |
>> dialogId := html nextId. self canvas div id: dialogId.
>> self canvas script: (html jQuery new dialog id:
> dialogId;
>> html: someComponent;
>> title: 'Title;
>> width: 600;
>> addButton: 'Accept' do: (html javascript
>> goto: (html jQuery get
>> callback: [
>> "This is fake code, but shows
> what I need :)"
>> self doSomethingLikeRemoveARow.
>> self refreshReport ];
>> fullUrl));
>> addButton: 'Cancel' do: html jQuery new dialog close;
>> resizable: false;
>> modal: true
>> autoOpen: true).
>>
>>
>> again, this is a simplified version of something I do for reef, but it
> shows more or less what I want... and I get a blank page all the time...
>>
>> Any idea how to solve this?
>>
>> Cheers,
>> Esteban
>>
>>
>> _______________________________________________
>> 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: a problem using javascript goto and jquery and some complex stuff

Robert Sirois
Maybe try doing something like this?

...
onClick: ( html jQuery ajax script: [:s | self someMethodThatMayReturnJavascriptOn: html ] );
...

RS

> To: [hidden email]
> From: [hidden email]
> Date: Wed, 3 Nov 2010 09:04:47 -0300
> Subject: [Seaside] Re: a problem using javascript goto and jquery and some complex stuff
>
> Hi,
> What I really want is to force a page refresh, but decide when this is
> necesary inside a javascript callback. For example, I open a "confirm
> dialog"... y you cancel the operation, nothing happens, but if you
> agree, a new page is rendered (not an ajax part, a whole new page),
> this is more or less the behavior I'm needing (something like the large
> example below).
> btw... I tryed using "html jQuery ajax" instead "html jQuery get" (and
> in fact I also tested with "post"), with exactly the same result for
> this issue.
>
> Cheers,
> Esteban
>
> On 2010-11-03 03:54:17 -0300, Johan Brichau <[hidden email]> said:
>
> > Hi Esteban,
> >
> > The goto makes your browser navigate to the url of an ajax callback.
> > That will execute the callback server-side but the response of that
> > callback is empty, hence the blank page. I think the use of #call: will
> > trigger a redirect in the callback, hence why that is working (just
> > writing this of the top of my head, did not verify). You either need to
> > use normal callbacks, or use jQuery to add or replace the html inline on
> > your webpage. Something along the lines of:
> >
> > html anchor
> > onClick: (html jQuery ajax
> > callback:[self
> > doSomethingLikeRemoveARow];
> > onComplete:(html jQuery
> > ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r |
> > tabsComponent renderOn: r]) ]);
> > with: 'goto blah'.
> >
> > -or-
> >
> > html anchor
> > callback: [self doSomethingLikeRemoveARow. self show:
> > tabsComponent ];
> > with: 'goto blah'.
> >
> > In the first case, it's important that you cancel the default behavior
> > of the anchor because otherwise it will execute a full callback instead
> > of an ajax request only. I'm always sending 'url: 'javascript:{}' to
> > such an anchor to cancel the default generated Seaside url, but there
> > are other ways.
> >
> > Hope it helps
> > Johan
> >
> > On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:
> >
> >> Hi,
> >> I have a problem dealing with some ajax renderization... I have
> > something like this:
> >>
> >> html anchor onClick: (html javascript
> > goto: (html jQuery get callback: [ self show:
> > tabsComponent ];
> >> fullUrl));
> >> with: 'goto blah'.
> >>
> >>
> >> of course, this is not my real need, just a simplified version :)
> >>
> >> and whenever the callback is executed, it just renders a blank page...
> > but if I change the #show: for #call:, the new component is rendered
> > correctly... I think this is not correct, because same behavior is
> > happening in other contexts (for example, I want to execute a callback
> > after render a confirmation dialog, something like this:
> >>
> >> | dialogId |
> >> dialogId := html nextId. self canvas div id: dialogId.
> >> self canvas script: (html jQuery new dialog id:
> > dialogId;
> >> html: someComponent;
> >> title: 'Title;
> >> width: 600;
> >> addButton: 'Accept' do: (html javascript
> >> goto: (html jQuery get
> >> callback: [
> >> "This is fake code, but shows
> > what I need :)"
> >> self doSomethingLikeRemoveARow.
> >> self refreshReport ];
> >> fullUrl));
> >> addButton: 'Cancel' do: html jQuery new dialog close;
> >> resizable: false;
> >> modal: true
> >> autoOpen: true).
> >>
> >>
> >> again, this is a simplified version of something I do for reef, but it
> > shows more or less what I want... and I get a blank page all the time...
> >>
> >> Any idea how to solve this?
> >>
> >> Cheers,
> >> Esteban
> >>
> >>
> >> _______________________________________________
> >> 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: a problem using javascript goto and jquery and some complex stuff

Johan Brichau-2
In reply to this post by EstebanLM
Hi Esteban,

You can do that by putting the goto inside a script callback.

(I'm in a meeting right now, will reply with an example later)

On 03 Nov 2010, at 13:04, Esteban Lorenzano wrote:

> Hi,
> What I really want is to force a page refresh, but decide when this is necesary inside a javascript callback. For example, I open a "confirm dialog"... y you cancel the operation, nothing happens, but if you agree, a new page is rendered (not an ajax part, a whole new page), this is more or less the behavior I'm needing (something like the large example below).
> btw... I tryed using "html jQuery ajax" instead "html jQuery get" (and in fact I also tested with "post"), with exactly the same result for this issue.
>
> Cheers,
> Esteban
>
> On 2010-11-03 03:54:17 -0300, Johan Brichau <[hidden email]> said:
>
>> Hi Esteban,
>> The goto makes your browser navigate to the url of an ajax callback.
>> That will execute the callback server-side but the response of that
>> callback is empty, hence the blank page. I think the use of #call: will
>> trigger a redirect in the callback, hence why that is working (just
>> writing this of the top of my head, did not verify). You either need to
>> use normal callbacks, or use jQuery to add or replace the html inline on
>> your webpage. Something along the lines of:
>> html anchor
>> onClick: (html jQuery ajax
>> callback:[self
>> doSomethingLikeRemoveARow];
>> onComplete:(html jQuery
>> ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r |
>> tabsComponent renderOn: r])  ]);
>> with: 'goto blah'.
>> -or-
>> html anchor
>> callback: [self doSomethingLikeRemoveARow. self show:
>> tabsComponent ];
>> with: 'goto blah'.
>> In the first case, it's important that you cancel the default behavior
>> of the anchor because otherwise it will execute a full callback instead
>> of an ajax request only. I'm always sending 'url: 'javascript:{}' to
>> such an anchor to cancel the default generated Seaside url, but there
>> are other ways.
>> Hope it helps
>> Johan
>> On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:
>>> Hi,
>>> I have a problem dealing with some ajax renderization... I have
>> something like this:
>>> html anchor onClick: (html javascript
>> goto: (html jQuery get callback: [ self show:
>> tabsComponent ];
>>> fullUrl));
>>> with: 'goto blah'.
>>> of course, this is not my real need, just a simplified version :)
>>> and whenever the callback is executed, it just renders a blank page...
>> but if I change the #show: for #call:, the new component is rendered
>> correctly... I think this is not correct, because same behavior is
>> happening in other contexts (for example, I want to execute a callback
>> after render a confirmation dialog, something like this:
>>> | dialogId |
>>> dialogId := html nextId. self canvas div id: dialogId.
>>> self canvas script: (html jQuery new dialog id:
>> dialogId;
>>> html: someComponent;
>>> title: 'Title;
>>> width: 600;
>>> addButton: 'Accept' do: (html javascript
>>> goto: (html jQuery get
>>> callback: [
>>> "This is fake code, but shows
>> what I need :)"
>>> self doSomethingLikeRemoveARow.
>>> self refreshReport ];
>>> fullUrl));
>>> addButton: 'Cancel' do: html jQuery new dialog close;
>>> resizable: false;
>>> modal: true
>>> autoOpen: true).
>>> again, this is a simplified version of something I do for reef, but it
>> shows more or less what I want... and I get a blank page all the time...
>>> Any idea how to solve this?
>>> Cheers,
>>> Esteban
>>> _______________________________________________
>>> 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: a problem using javascript goto and jquery and some complex stuff

Johan Brichau-2
In reply to this post by EstebanLM
Hi Esteban,

For the dialog box, I think this corresponds to what you outline:

        | dialogId |
        dialogId := html nextId.
        self canvas div id: dialogId.
        self canvas script: (html jQuery new dialog
                id: dialogId;
                html: someComponent;
                title: 'Title;
                width: 600;
                addButton: 'Accept' do:
                        (html jQuery ajax
                                        callback: [ "This is fake code, but shows what I need :)"
                                                        self doSomethingLikeRemoveARow.
                                                        self refreshReport ];
                                        onComplete: (html javascript refresh));
                addButton: 'Cancel' do: (html jQuery id: dialogId) close;
                resizable: false;
                modal: true
                autoOpen: true).


The accept button will execute an ajax callback that triggers a page refresh on completion.
The cancel button will simply remove the dialog from the page.

Now, if you want to decide server-side on what kind of behavior to execute on the client-side, you can pass this to the button:

(html jQuery ajax script: [:s | self closeDialog
                                                        ifTrue:[ s << (s jQuery id: dialogId) close]
                                                        ifFalse: [s << (s refresh)]]

It's also useful to note that you can easily pass the link to a full callback in a javascript like this:

html javascript callback: [ self show: aComponent]

Does this help?

Cheers
Johan

On 03 Nov 2010, at 13:04, Esteban Lorenzano wrote:

> Hi,
> What I really want is to force a page refresh, but decide when this is necesary inside a javascript callback. For example, I open a "confirm dialog"... y you cancel the operation, nothing happens, but if you agree, a new page is rendered (not an ajax part, a whole new page), this is more or less the behavior I'm needing (something like the large example below).
> btw... I tryed using "html jQuery ajax" instead "html jQuery get" (and in fact I also tested with "post"), with exactly the same result for this issue.
>
> Cheers,
> Esteban
>
> On 2010-11-03 03:54:17 -0300, Johan Brichau <[hidden email]> said:
>
>> Hi Esteban,
>> The goto makes your browser navigate to the url of an ajax callback.
>> That will execute the callback server-side but the response of that
>> callback is empty, hence the blank page. I think the use of #call: will
>> trigger a redirect in the callback, hence why that is working (just
>> writing this of the top of my head, did not verify). You either need to
>> use normal callbacks, or use jQuery to add or replace the html inline on
>> your webpage. Something along the lines of:
>> html anchor
>> onClick: (html jQuery ajax
>> callback:[self
>> doSomethingLikeRemoveARow];
>> onComplete:(html jQuery
>> ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r |
>> tabsComponent renderOn: r])  ]);
>> with: 'goto blah'.
>> -or-
>> html anchor
>> callback: [self doSomethingLikeRemoveARow. self show:
>> tabsComponent ];
>> with: 'goto blah'.
>> In the first case, it's important that you cancel the default behavior
>> of the anchor because otherwise it will execute a full callback instead
>> of an ajax request only. I'm always sending 'url: 'javascript:{}' to
>> such an anchor to cancel the default generated Seaside url, but there
>> are other ways.
>> Hope it helps
>> Johan
>> On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:
>>> Hi,
>>> I have a problem dealing with some ajax renderization... I have
>> something like this:
>>> html anchor onClick: (html javascript
>> goto: (html jQuery get callback: [ self show:
>> tabsComponent ];
>>> fullUrl));
>>> with: 'goto blah'.
>>> of course, this is not my real need, just a simplified version :)
>>> and whenever the callback is executed, it just renders a blank page...
>> but if I change the #show: for #call:, the new component is rendered
>> correctly... I think this is not correct, because same behavior is
>> happening in other contexts (for example, I want to execute a callback
>> after render a confirmation dialog, something like this:
>>> | dialogId |
>>> dialogId := html nextId. self canvas div id: dialogId.
>>> self canvas script: (html jQuery new dialog id:
>> dialogId;
>>> html: someComponent;
>>> title: 'Title;
>>> width: 600;
>>> addButton: 'Accept' do: (html javascript
>>> goto: (html jQuery get
>>> callback: [
>>> "This is fake code, but shows
>> what I need :)"
>>> self doSomethingLikeRemoveARow.
>>> self refreshReport ];
>>> fullUrl));
>>> addButton: 'Cancel' do: html jQuery new dialog close;
>>> resizable: false;
>>> modal: true
>>> autoOpen: true).
>>> again, this is a simplified version of something I do for reef, but it
>> shows more or less what I want... and I get a blank page all the time...
>>> Any idea how to solve this?
>>> Cheers,
>>> Esteban
>>> _______________________________________________
>>> 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: a problem using javascript goto and jquery and some complex stuff

EstebanLM
Cool, seems to be working this way. Thank you very much!

Cheers,
Esteban

On 2010-11-03 16:16:01 -0300, Johan Brichau <[hidden email]> said:

> Hi Esteban,
>
> For the dialog box, I think this corresponds to what you outline:
>
> | dialogId |
> dialogId := html nextId.
>         self canvas div id: dialogId.
> self canvas script: (html jQuery new dialog
> id: dialogId;
> html: someComponent;
> title: 'Title;
> width: 600;
> addButton: 'Accept' do:
> (html jQuery ajax
> callback: [ "This is fake code,
> but shows what I need :)"
> self
> doSomethingLikeRemoveARow.
> self
> refreshReport ];
> onComplete: (html javascript
> refresh));
> addButton: 'Cancel' do: (html jQuery id: dialogId)
> close;
> resizable: false;
> modal: true
> autoOpen: true).
>
>
> The accept button will execute an ajax callback that triggers a page
> refresh on completion.
> The cancel button will simply remove the dialog from the page.
>
> Now, if you want to decide server-side on what kind of behavior to
> execute on the client-side, you can pass this to the button:
>
> (html jQuery ajax script: [:s | self closeDialog
> ifTrue:[ s << (s
> jQuery id: dialogId) close]
> ifFalse: [s <<
> (s refresh)]]
>
> It's also useful to note that you can easily pass the link to a full
> callback in a javascript like this:
>
> html javascript callback: [ self show: aComponent]
>
> Does this help?
>
> Cheers
> Johan
>
> On 03 Nov 2010, at 13:04, Esteban Lorenzano wrote:
>
>> Hi,
>> What I really want is to force a page refresh, but decide when this is
> necesary inside a javascript callback. For example, I open a "confirm
> dialog"... y you cancel the operation, nothing happens, but if you
> agree, a new page is rendered (not an ajax part, a whole new page), this
> is more or less the behavior I'm needing (something like the large
> example below).
>> btw... I tryed using "html jQuery ajax" instead "html jQuery get" (and
> in fact I also tested with "post"), with exactly the same result for
> this issue.
>>
>> Cheers,
>> Esteban
>>
>> On 2010-11-03 03:54:17 -0300, Johan Brichau <[hidden email]> said:
>>
>>> Hi Esteban,
>>> The goto makes your browser navigate to the url of an ajax callback.
>>> That will execute the callback server-side but the response of that
>>> callback is empty, hence the blank page. I think the use of #call:
> will
>>> trigger a redirect in the callback, hence why that is working (just
>>> writing this of the top of my head, did not verify). You either need
> to
>>> use normal callbacks, or use jQuery to add or replace the html inline
> on
>>> your webpage. Something along the lines of:
>>> html anchor
>>> onClick: (html jQuery ajax
>>> callback:[self
>>> doSomethingLikeRemoveARow];
>>> onComplete:(html jQuery
>>> ajax) script:[:s | s << ((s jQuery expression: 'body') append: [:r |
>>> tabsComponent renderOn: r])  ]);
>>> with: 'goto blah'.
>>> -or-
>>> html anchor
>>> callback: [self doSomethingLikeRemoveARow. self show:
>>> tabsComponent ];
>>> with: 'goto blah'.
>>> In the first case, it's important that you cancel the default
> behavior
>>> of the anchor because otherwise it will execute a full callback
> instead
>>> of an ajax request only. I'm always sending 'url: 'javascript:{}' to
>>> such an anchor to cancel the default generated Seaside url, but there
>>> are other ways.
>>> Hope it helps
>>> Johan
>>> On 03 Nov 2010, at 01:09, Esteban Lorenzano wrote:
>>>> Hi,
>>>> I have a problem dealing with some ajax renderization... I have
>>> something like this:
>>>> html anchor onClick: (html javascript
>
>>> goto: (html jQuery get callback: [ self
> show:
>>> tabsComponent ];
>>>> fullUrl));
>>>> with: 'goto blah'.
>>>> of course, this is not my real need, just a simplified version :)
>>>> and whenever the callback is executed, it just renders a blank
> page...
>>> but if I change the #show: for #call:, the new component is rendered
>>> correctly... I think this is not correct, because same behavior is
>>> happening in other contexts (for example, I want to execute a
> callback
>>> after render a confirmation dialog, something like this:
>>>> | dialogId |
>>>> dialogId := html nextId. self canvas div id: dialogId.
>>>> self canvas script: (html jQuery new dialog id:
>>> dialogId;
>>>> html: someComponent;
>>>> title: 'Title;
>>>> width: 600;
>>>> addButton: 'Accept' do: (html javascript
>>>> goto: (html jQuery get
>>>> callback: [
>>>> "This is fake code, but shows
>>> what I need :)"
>>>> self doSomethingLikeRemoveARow.
>>>> self refreshReport ];
>>>> fullUrl));
>>>> addButton: 'Cancel' do: html jQuery new dialog close;
>>>> resizable: false;
>>>> modal: true
>>>> autoOpen: true).
>>>> again, this is a simplified version of something I do for reef, but
> it
>>> shows more or less what I want... and I get a blank page all the
> time...
>>>> Any idea how to solve this?
>>>> Cheers,
>>>> Esteban
>>>> _______________________________________________
>>>> 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
|

Javascript question

Phil
In reply to this post by Johan Brichau-2
Hi all,

I'm learning the JS Classes and have a couple of issues I can't find answers to.

To create the following function:

function(node) {
        if (node.leaf) {
                node.onClick(node.id);
                {$.ajax({"url":"/CQNowS","data":["_s=VPFmqrxxYQGh1ycn","_k=wjnMpQBbQbIebYiP","2","3="+node.id].join("&")})}
        }
}

i'm using:

(html javascript
        alias: 'node';
        call: 'onClick' with: 'node.id';
        condition: 'node.leaf') asFunction: #(node)

however it renders:

function(node){if("node.leaf"){node.onClick("node.id")}}

How do I make the "node.leaf" and "node.id" into references rather than strings?

And then how to I get the following into the condition?

jQuery ajax
        callback: [:value | self nodeSelected: (self passengerAt: value)]
        value: 'node.id'))

Any pointers would be much appreciated.

Cheers,

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

Re: Javascript question

Lukas Renggli
> To create the following function:
>
> function(node) {
>        if (node.leaf) {
>                node.onClick(node.id);
>                {$.ajax({"url":"/CQNowS","data":["_s=VPFmqrxxYQGh1ycn","_k=wjnMpQBbQbIebYiP","2","3="+node.id].join("&")})}
>        }
> }

The point of the Javascript support classes *is not* to create
complicated code like this (although it can be done). The idea is
compose and configure different existing parts with each other. In
your case I suggest that you put your Javascript functionality into an
external Javascript file, create your own Seaside wrapper and call it
from Smalltalk.

> function(node){if("node.leaf"){node.onClick("node.id")}}
>
> How do I make the "node.leaf" and "node.id" into references rather than strings?

JSStream on: 'node.id'

Lukas

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

Re: Javascript question

Bart Veenstra
Hi Phil,

Looks like you are creating a tree component? which JS library do you use for that? I already implemented JSTree so maybe we can join forces?

Regards,

Bart

2010/11/20 Lukas Renggli <[hidden email]>
> To create the following function:
>
> function(node) {
>        if (node.leaf) {
>                node.onClick(node.id);
>                {$.ajax({"url":"/CQNowS","data":["_s=VPFmqrxxYQGh1ycn","_k=wjnMpQBbQbIebYiP","2","3="+node.id].join("&")})}
>        }
> }

The point of the Javascript support classes *is not* to create
complicated code like this (although it can be done). The idea is
compose and configure different existing parts with each other. In
your case I suggest that you put your Javascript functionality into an
external Javascript file, create your own Seaside wrapper and call it
from Smalltalk.

> function(node){if("node.leaf"){node.onClick("node.id")}}
>
> How do I make the "node.leaf" and "node.id" into references rather than strings?

JSStream on: 'node.id'

Lukas

--
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
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