Discussion:
onclick
Haris Bogdanovich
2012-04-09 22:38:01 UTC
Permalink
Hi.

Why doesn't this piece of code work:

(defpackage test (:use :cl :hunchentoot :cl-who :parenscript))
(in-package test)

(defun index ()
(with-html-output-to-string (*standard-output* nil)
(:html
(:head)
(:body
(:p "click me" :onclick (ps (alert "hello")))))))

(push (create-prefix-dispatcher "/index" 'index) *dispatch-table*)

(start (make-instance 'easy-acceptor))

I loaded Edi's init file for Lispworks and I can't even autocomplete :onclick ?
When I click on "click me" nothing happens ?

Thanks
Haris Bogdanovich
2012-04-12 10:52:11 UTC
Permalink
I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
with the latest quicklisp but I can't still autocomplete :onclick.
If I just write it the program stilll doesn't work.
What could be the problem ?
Stas Boukarev
2012-04-12 14:45:03 UTC
Permalink
Content preview: "Haris Bogdanovich" <***@xnet.hr> writes: > I installed
all the libraries (cl-who, parenscript and hunchentoot) properlly > with
the latest quicklisp but I can't still autocomplete :onclick. You shouldn't
be able to autocomplete :onclick. Autocomplete in slime works only for interned
symbols, once you compile the code it will be interned and you would see
it in the autocompletion. cl-who doesn't intern symbols into keyword for it
to work. [...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.217.179 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
(stassats[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
Archived-At: <http://permalink.gmane.org/gmane.lisp.who.general/300>
Post by Haris Bogdanovich
I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
with the latest quicklisp but I can't still autocomplete :onclick.
You shouldn't be able to autocomplete :onclick. Autocomplete in slime
works only for interned symbols, once you compile the code it will be
interned and you would see it in the autocompletion. cl-who doesn't
intern symbols into keyword for it to work.
Post by Haris Bogdanovich
If I just write it the program stilll doesn't work.
What could be the problem ?
:onclick should come before the body of <p>, so,

(with-html-output-to-string (*standard-output* nil)
(:html
(:head)
(:body
(:p :onclick "alert(\"Hello\")"
"click me"))))

I don't know how parenscript is supposed to work, but (ps (alert
"hello")) returns "alert('hello');", and cl-who uses #\' to quote
strings, so it becomes 'alert('hello');', which obviously doesn't work.
--
With best regards, Stas.
Stas Boukarev
2012-04-12 14:47:32 UTC
Permalink
Content preview: Stas Boukarev <***@gmail.com> writes: > "Haris Bogdanovich"
<***@xnet.hr> writes: > >> I installed all the libraries (cl-who,
parenscript and hunchentoot) properlly >> with the latest quicklisp but I
can't still autocomplete :onclick. > You shouldn't be able to autocomplete
:onclick. Autocomplete in slime > works only for interned symbols, once you
compile the code it will be > interned and you would see it in the autocompletion.
cl-who doesn't > intern symbols into keyword for it to work. > >> If I just
write it the program stilll doesn't work. >> What could be the problem ?
:onclick should come before the body of <p>, so, > > (with-html-output-to-string
(*standard-output* nil) > (:html > (:head) > (:body > (:p :onclick "alert(\"Hello\")"
"click me")))) > > I don't know how parenscript is supposed to work, but
(ps (alert > "hello")) returns "alert('hello');", and cl-who uses #\' to
quote > strings, so it becomes 'alert('hello');', which obviously doesn't
work. [...]

Content analysis details: (-100.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.217.179 listed in list.dnswl.org]
-100 USER_IN_WHITELIST From: address is in the user's white-list
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
(stassats[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
Archived-At: <http://permalink.gmane.org/gmane.lisp.who.general/301>
Post by Haris Bogdanovich
I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
with the latest quicklisp but I can't still autocomplete :onclick.
You shouldn't be able to autocomplete :onclick. Autocomplete in slime
works only for interned symbols, once you compile the code it will be
interned and you would see it in the autocompletion. cl-who doesn't
intern symbols into keyword for it to work.
Post by Haris Bogdanovich
If I just write it the program stilll doesn't work.
What could be the problem ?
:onclick should come before the body of <p>, so,
(with-html-output-to-string (*standard-output* nil)
(:html
(:head)
(:body
(:p :onclick "alert(\"Hello\")"
"click me"))))
I don't know how parenscript is supposed to work, but (ps (alert
"hello")) returns "alert('hello');", and cl-who uses #\' to quote
strings, so it becomes 'alert('hello');', which obviously doesn't work.
(setf ps:*js-string-delimiter* #\") for

(:p :onclick (ps (alert "hello")) "click me")

to work.
--
With best regards, Stas.
Andy Peterson
2012-04-12 15:55:13 UTC
Permalink
Content preview: On Thu, Apr 12, 2012 at 10:47 AM, Stas Boukarev <***@gmail.com>
wrote: > > Stas Boukarev <***@gmail.com> writes: > > > "Haris Bogdanovich"
<***@xnet.hr> writes: > > > >> I installed all the libraries (cl-who,
parenscript and hunchentoot) properlly > >> with the latest quicklisp but
I can't still autocomplete :onclick. > > You shouldn't be able to autocomplete
:onclick. Autocomplete in slime > > works only for interned symbols, once
you compile the code it will be > > interned and you would see it in the
autocompletion. cl-who doesn't > > intern symbols into keyword for it to work.
Post by Haris Bogdanovich
If I just write it the program stilll doesn't work. > >> What could
be the problem ? > > :onclick should come before the body of <p>, so, > >
(with-html-output-to-string (*standard-output* nil) > > (:html > > (:head)
(:body > > (:p :onclick "alert(\"Hello\")" > > "click me")))) > > > >
I don't know how parenscript is supposed to work, but (ps (alert > > "hello"))
returns "alert('hello');", and cl-who uses #\' to quote > > strings, so it
becomes 'alert('hello');', which obviously doesn't work. > > (setf ps:*js-string-delimiter*
#\") for > > (:p :onclick (ps (alert "hello")) "click me") > > to work. >
-- > With best regards, Stas. > [...]
Content analysis details: (-0.7 points, 5.0 required)

pts rule name description
---- ---------------------- --------------------------------------------------
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.217.179 listed in list.dnswl.org]
0.0 SINGLE_HEADER_2K A single header contains 2K-3K characters
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
(andy.arvid[at]gmail.com)
-0.0 SPF_PASS SPF: sender matches SPF record
0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid
Archived-At: <http://permalink.gmane.org/gmane.lisp.who.general/302>
Post by Haris Bogdanovich
I installed all the libraries (cl-who, parenscript and hunchentoot) properlly
with the latest quicklisp but I can't still autocomplete :onclick.
You shouldn't be able to autocomplete :onclick. Autocomplete in slime
works only for interned symbols, once you compile the code it will be
interned and you would see it in the autocompletion. cl-who doesn't
intern symbols into keyword for it to work.
Post by Haris Bogdanovich
If I just write it the program stilll doesn't work.
What could be the problem ?
:onclick should come before the body of <p>, so,
(with-html-output-to-string (*standard-output* nil)
    (:html
     (:head)
     (:body
      (:p :onclick "alert(\"Hello\")"
          "click me"))))
I don't know how parenscript is supposed to work, but (ps (alert
"hello")) returns "alert('hello');", and cl-who uses #\' to quote
strings, so it becomes 'alert('hello');', which obviously doesn't work.
(setf ps:*js-string-delimiter* #\") for
(:p :onclick (ps (alert "hello")) "click me")
to work.
--
With best regards, Stas.
(PS-INLINE form &optional *JS-STRING-DELIMITER*)
(PS-INLINE* form &optional *JS-STRING-DELIMITER*)
PS-INLINE and PS-INLINE* take a single Parenscript form and output a
string starting with javascript: that can be used in HTML node
attributes. As well, they provide an argument to bind the value of
*JS-STRING-DELIMITER* to control the value of the JavaScript string
escape character to be compatible with whatever the HTML generation
mechanism is used (for example, if HTML strings are delimited using
#\', using #\" will avoid conflicts without requiring the output
JavaScript code to be escaped). By default the value is taken from
*JS-INLINE-STRING-DELIMITER*.

comment: the default value for  *JS-INLINE-STRING-DELIMITER* is #\"
Loading...