Calling a JQuery enabled component from an anchor callback

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

Calling a JQuery enabled component from an anchor callback

John Toohey
I have a table that includes a html anchor with a callback in the
first column. The callback calls #render: self TestComponent when
clicked, and the #renderContentOn method of the component called is :-

renderContentOn: html
        html div id: #JPT;
                 script: (html jQuery new dialog
                        title: 'Test';
                        autoOpen: true;
                        addButton: 'Close' do: html jQuery new dialog close);
                with: [html text: 'Hello World'].
                self halt

I get a MessageNotUnderstood: UndefinedObject>>addLoadScript: in the
browser when its called. I am trying to have a JQuery dialog popup and
allow me to edit the contents of the tablerow, but I am not sure what
I am doing wrong here.

I want to create this dialog each time a row is clicked, as I need to
populate the form with the current values. Is there an issue injecting
a script like this into a rendered page?

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

Re: Calling a JQuery enabled component from an anchor callback

Lukas Renggli
> I have a table that includes a html anchor with a callback in the
> first column. The callback calls #render: self TestComponent when
> clicked, and the #renderContentOn method of the component called is :-

Could you post the code that renders the anchor and the callback?

> renderContentOn: html
>        html div id: #JPT;
>                 script: (html jQuery new dialog
>                        title: 'Test';
>                        autoOpen: true;
>                        addButton: 'Close' do: html jQuery new dialog close);
>                with: [html text: 'Hello World'].
>                self halt
>
> I get a MessageNotUnderstood: UndefinedObject>>addLoadScript: in the
> browser when its called. I am trying to have a JQuery dialog popup and
> allow me to edit the contents of the tablerow, but I am not sure what
> I am doing wrong here.

That code looks fine and works well, as far as I can tell.

Cheers,
Lukas

--
Lukas Renggli
http://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: Calling a JQuery enabled component from an anchor callback

John Toohey-2
This is the snippet from the table row render that has the anchor :-

        html tableRow id: id; with:
                [html
                        tableData: [html anchor callback: [html render: self
testComponent]; with: 'Edit'];
                        tableData: aJulietUser role;


On Sat, Apr 18, 2009 at 05:24, Lukas Renggli <[hidden email]> wrote:

>> I have a table that includes a html anchor with a callback in the
>> first column. The callback calls #render: self TestComponent when
>> clicked, and the #renderContentOn method of the component called is :-
>
> Could you post the code that renders the anchor and the callback?
>
>> renderContentOn: html
>>        html div id: #JPT;
>>                 script: (html jQuery new dialog
>>                        title: 'Test';
>>                        autoOpen: true;
>>                        addButton: 'Close' do: html jQuery new dialog close);
>>                with: [html text: 'Hello World'].
>>                self halt
>>
>> I get a MessageNotUnderstood: UndefinedObject>>addLoadScript: in the
>> browser when its called. I am trying to have a JQuery dialog popup and
>> allow me to edit the contents of the tablerow, but I am not sure what
>> I am doing wrong here.
>
> That code looks fine and works well, as far as I can tell.
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



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

Re: Calling a JQuery enabled component from an anchor callback

Lukas Renggli
> This is the snippet from the table row render that has the anchor :-
>
>        html tableRow id: id; with:
>                [html
>                        tableData: [html anchor callback: [html render: self
> testComponent]; with: 'Edit'];
>                        tableData: aJulietUser role;

The problem with the above code is that when the callback is executed
the reference to the html canvas is not valid anymore. Remember, the
callback is only evaluated later, after the page has been renderer and
sent of to the web browser.

A possible solution would be to use an jQuery load action that on a
specific DOM element. This gives you a new html renderer to render on.
Try something along and check out other examples like
JQCounterFunctionalTest:

  " an empty div that will be the target of the rendering "
  html div id: 'dialogTarget'.

  " the anchor triggering the dialog (the jQu"
  html anchor
    onClick: ((html jQuery: 'dialogTarget') load
      html: [ :r | r render: self textComponent ]));
    with: 'Edit'

Btw, there is a Slime rule that detects when you accidently use a
wrong renderer.

Cheers,
Lukas

--
Lukas Renggli
http://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: Calling a JQuery enabled component from an anchor callback

John Toohey-2
Lukas,
Perfect, many thanks.

On Sat, Apr 18, 2009 at 12:10, Lukas Renggli <[hidden email]> wrote:

>> This is the snippet from the table row render that has the anchor :-
>>
>>        html tableRow id: id; with:
>>                [html
>>                        tableData: [html anchor callback: [html render: self
>> testComponent]; with: 'Edit'];
>>                        tableData: aJulietUser role;
>
> The problem with the above code is that when the callback is executed
> the reference to the html canvas is not valid anymore. Remember, the
> callback is only evaluated later, after the page has been renderer and
> sent of to the web browser.
>
> A possible solution would be to use an jQuery load action that on a
> specific DOM element. This gives you a new html renderer to render on.
> Try something along and check out other examples like
> JQCounterFunctionalTest:
>
>  " an empty div that will be the target of the rendering "
>  html div id: 'dialogTarget'.
>
>  " the anchor triggering the dialog (the jQu"
>  html anchor
>    onClick: ((html jQuery: 'dialogTarget') load
>      html: [ :r | r render: self textComponent ]));
>    with: 'Edit'
>
> Btw, there is a Slime rule that detects when you accidently use a
> wrong renderer.
>
> Cheers,
> Lukas
>
> --
> Lukas Renggli
> http://www.lukas-renggli.ch
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
-JT
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside