I would like to attach an onClick event according to

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

Re: I would like to attach an onClick event according to

littleSmalltalker
Hi,
The double quotes seem to be a result of attributes values which are not handled correctly (i.e. double quotes converted to single quotes). This applies to attributes escaping and the jQuery+Prototype libraries.

Fritz - the fact that JQueryInstance outputs double quotes might be true, however there's a deeper problem here - WAHtmlAttributes inserts every attribute value as-is, without escaping / converting quotes.Therefore such erroneous code can also result from a simple onClick message passed to (html button), regardless of jQuery.
Whatever the solution may be, the resulting code must not put double quotes within attribute values since it is not considered standard. I've filed a fix for the issue by replacing double quotes with single quotes, however this calls for more elaborate solution since there are other libraries involved.

Cheers,
Avi.
On Sun, Feb 6, 2011 at 11:21 PM, Bob Arning <[hidden email]> wrote:
On 2/6/11 2:35 PM, Fritz Schenk wrote:
John, thank you for taking the time to recreate the test. It teaches me how to
use Seaside more efficiently. Except for the<break>s it is exactly the
http://jsbin.com/imuka5/2

However, neither
<myAttach>  html button

       onClick: ((html jQuery expression: '#external_links a')
               onClick: 'return confirm("You are going to visit: "+ this.href)');

       with: 'Fritz''s Attach Click'.
/myAttach>              
or,
<yourAttach>  html button

 onClick: ( (html jQuery expression: '#external_links a')

 call: 'click' with: ('return confirm("You are going to visit: " + this.href)'
asFunction));

       with: 'My Attach Click'
<yourAttach>

Work. What the small application incorrectly brings up the inspector in the
callback of the anchor without output of the confirm dialog.
The reason being that the above two attaches are translated into code with
the same problem. The embedded double quotes are the problem.

<as per source in halos>
<button onclick="$("#external_links a").click(function(){return confirm
("You are going to visit: "+ this.href)})" type="submit" class="submit">
Fritz's Attach Click</button>
<button onclick="$("#external_links a").click(function(){return confirm
("You are going to visit: " + this.href)})" type="submit" class="submit">
My Attach Click</button>
<as per source in halos>

Notice that the onClick:... and call:... messages generate exactly the same code.

I have reported this problem.



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

Fritz,

Not sure where you are seeing the embedded double quotes, but if I run this code and View Source in my browser (Safari), it looks like Seaside has sent this:

<button onclick="$(&quot;#external_links a&quot;).click(function(){return confirm(&quot;You are going to visit: &quot;+ this.href)})" type="submit" class="submit">Fritz's Attach Click</button>
<button onclick="$(&quot;#external_links a&quot;).click(function(){return confirm(&quot;You are going to visit: &quot; + this.href)})" type="submit" class="submit">My Attach Click</button>

no errors noted in the error console, so I'm not sure where the error is happening for you.

Also, (see attached snapshot) when I click on one of the anchors, I see the confirm dialog. If I click Cancel, the dialog goes away and that's it. If I click OK, then the callback is run (thus opening an inspector) after dismissing the dialog. Note sure why this doesn't meet your expectations.

Cheers,
Bob


_______________________________________________
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: I would like to attach an onClick event according to

Intrader Intrader
Avi, thanks for following this up. I have reported an error which may not be
the correct subject as I thought at the time that it was in asFunction.
http://code.google.com/p/seaside/issues/list?
cursor=640&start=100&updated=640&ts=1297027779

I think that you are pointing to the correct direction.

Bob, in a posting to the list has a version running on a Mac, and he seems to
get the quotes html encoded as &quot; which would work.



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

Re: I would like to attach an onClick event according to

Intrader Intrader
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Boris, since I had the namespace problem I did not pursue your code.

However, looking at your code and removing the namespace, works perfectly and
would provide an alternative to get the appropriate action. I will study this
thoroughly as it suggest knowledge way beyond of where I am at this time.

Thanks

P.S: I have reported a bug
http://code.google.com/p/seaside/issues/list?
cursor=640&start=100&updated=640&ts=1297027779

The subject of the bug is incorrect, as I now think that it is not in asFunction
but in the instantiation of a JQueryInstance expression:'external_links a'
which has changes the single quote to double quote.



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

Re: I would like to attach an onClick event according to

Intrader Intrader
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Boris, please try my code in Visual works to see it works as I have seen a
posting that suggest that some Seaside (or Pharo) implementation translates
the single quote to &quot; and that would work on.
Here is the code of renderContentOn
<code>
renderContentOn: html
    1 to: 5 do: [:x |
       html div id: 'external_links';
            with: [html anchor callback: [x inspect];
       with: x]].
    1 to: 5 do: [:x |
       html div id: '\"external_links\"';
       with: 'just some content'].
    html button
       onClick: ((html jQuery expression: 'external_links a')
           onClick: 'return confirm("You are going to visit: "+ this.href)');
</code>

As you see the code 'injects' elegantly the behavior I want without touching
the code of the HTML.


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

Re: I would like to attach an onClick event according to

Intrader Intrader
In reply to this post by John McKeon
John your code is beautiful! and it works

Thanks

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