String concatenation in javascript

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

String concatenation in javascript

Dave
Hi,
 I'm trying to update a textarea after a click on an anchor so I wrote this code:
html anchor onClick: ((html jQuery id: 'textAreaId') value: (html jQuery id: 'textAreaId') value , 'some text'); with: 'a label'.
Unfortunately it generates this html:
<a onclick="$("#textAreaId").val($("#textAreaId").val();"some text")">a label</a>

Instead I need an html like:
<a onclick="$("#textAreaId").val($("#textAreaId").val()+"some text")">a label</a>

i.e a string concatenation in javascript (see plus sign instead of semicolon).

I can't find anything on seaside image.
Can you help me?

Cheers
 Dave
Reply | Threaded
Open this post in threaded view
|

Re: String concatenation in javascript

Dave
I resend the message because the format was not correct.


Hi,
 I'm trying to update a textarea and I wrote this code:
html anchor onClick: ((html jQuery id: 'textAreaId') value: (html jQuery id: 'textAreaId') value , 'some text'); with: 'a label'.

Unfortunately it generates this html:
<a onclick="$("#textAreaId").val($("#textAreaId").val();"some text")">a label

Instead I need an html like:
<a onclick="$("#textAreaId").val($("#textAreaId").val()+"some text")">a label

i.e a string concatenation in javascript (see plus sign instead of semicolon).

I can't find anything on seaside image.
Can you help me?

Cheers
 Dave
Reply | Threaded
Open this post in threaded view
|

Re: String concatenation in javascript

Robert Sirois
Try adding parens like this (untested):

html anchor onClick: ((html jQuery id: 'textAreaId') value: ((html jQuery id: 'textAreaId') value), 'some text'); with: 'a label'.

It looks like the parser thinks that ... value, 'some text'... is two separate JavaScript statements, which is not your intent.

RS

> Date: Mon, 3 Jun 2013 17:43:38 -0700

> From: [hidden email]
> To: [hidden email]
> Subject: [Seaside] Re: String concatenation in javascript
>
> I resend the message because the format was not correct.
>
>
> Hi,
> I'm trying to update a textarea and I wrote this code:
> html anchor onClick: ((html jQuery id: 'textAreaId') value: (html jQuery id:
> 'textAreaId') value , 'some text'); with: 'a label'.
>
> Unfortunately it generates this html:
> a label
>
> Instead I need an html like:
> a label
>
> i.e a string concatenation in javascript (see plus sign instead of
> semicolon).
>
> I can't find anything on seaside image.
> Can you help me?
>
> Cheers
> Dave
>
>
>
>
> --
> View this message in context: http://forum.world.st/String-concatenation-in-javascript-tp4691470p4691471.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> 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: String concatenation in javascript

Johan Brichau-2
In reply to this post by Dave
The JSObject>>, is for concatenating generated javascript expressions. If you want to generate a javascript expression that does string concatenation, you need to write actual javascript.
Afaik, there is no Seaside method to generate string concatenation expressions.

I'm not seeing the stuff you might have pasted in your email correctly, but this is how I would write your expression:

html anchor
        onClick: ((html jQuery id: 'textAreaId') value: (JSStream on: '$(''#textAreaId'').value()+''some text'' '));
        with: 'a label'.


cheers,
Johan


On 04 Jun 2013, at 02:43, Dav <[hidden email]> wrote:

> I resend the message because the format was not correct.
>
>
> Hi,
> I'm trying to update a textarea and I wrote this code:
> html anchor onClick: ((html jQuery id: 'textAreaId') value: (html jQuery id:
> 'textAreaId') value , 'some text'); with: 'a label'.
>
> Unfortunately it generates this html:
> a label  
>
> Instead I need an html like:
> a label
>
> i.e a string concatenation in javascript (see plus sign instead of
> semicolon).
>
> I can't find anything on seaside image.
> Can you help me?
>
> Cheers
> Dave
>
>
>
>
> --
> View this message in context: http://forum.world.st/String-concatenation-in-javascript-tp4691470p4691471.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> 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: String concatenation in javascript

Dave
Johan Brichau-2 wrote
The JSObject>>, is for concatenating generated javascript expressions. If you want to generate a javascript expression that does string concatenation, you need to write actual javascript.
Afaik, there is no Seaside method to generate string concatenation expressions.
I guess you are right

I'm not seeing the stuff you might have pasted in your email correctly,
The expressions was:

Unfortunately it generates this html:
<a onclick="$("#textAreaId").val($("#textAreaId").val();"some text")">a label

Instead I need an html like:
<a onclick="$("#textAreaId").val($("#textAreaId").val()+"some text")">a label

but this is how I would write your expression:

html anchor
        onClick: ((html jQuery id: 'textAreaId') value: (JSStream on: '$(''#textAreaId'').value()+''some text'' '));
        with: 'a label'.


cheers,
Johan
Thanks Johan it works, even if there is a typo: value() instead of val()

The right one is:
html anchor
        onClick: ((html jQuery id: 'textAreaId') value: (JSStream on: '$(''#textAreaId'').val()+''some text'' '));
        with: 'a label'.

Cheers,
 Dave
Reply | Threaded
Open this post in threaded view
|

Re: String concatenation in javascript

Winfried Jacobs-2
Hello Dave,

with a little extra method in JSObject (*) you could even write it completely in
Smalltalk:

   html anchor
       onClick: (
           (html jQuery id: 'textAreaId') value: (
               html jQuery id: 'textAreaId') value + 'some text'
               );
       with: 'a label'.


(*) Method #+ in JSObject defined like this:

+ anObject
    "Combine the receiver and anObject with a plus sign"

    self addDecoration: (JSBinary new operator: '+'; statement: anObject)


Best regards
Winfried



> Dav <[hidden email]> hat am 4. Juni 2013 um 17:23 geschrieben:
>
>
> Johan Brichau-2 wrote
> > The JSObject>>, is for concatenating generated javascript expressions. If
> > you want to generate a javascript expression that does string
> > concatenation, you need to write actual javascript.
> > Afaik, there is no Seaside method to generate string concatenation
> > expressions.
>
> I guess you are right
>
>
> > I'm not seeing the stuff you might have pasted in your email correctly,
>
> The expressions was:
>
> Unfortunately it generates this html:
> a label
>
> Instead I need an html like:
> a label
>
>
> > but this is how I would write your expression:
> >
> > html anchor
> > onClick: ((html jQuery id: 'textAreaId') value: (JSStream on:
> > '$(''#textAreaId'').value()+''some text'' '));
> > with: 'a label'.
> >
> >
> > cheers,
> > Johan
>
> Thanks Johan it works, even if there is a typo: value() instead of val()
>
> The right one is:
> html anchor
> onClick: ((html jQuery id: 'textAreaId') value: (JSStream on:
> '$(''#textAreaId'').val()+''some text'' '));
> with: 'a label'.
>
> Cheers,
> Dave
>
>
>
> --
> View this message in context:
> http://forum.world.st/String-concatenation-in-javascript-tp4691470p4691616.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> 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: String concatenation in javascript

Dave
Yep Winfried, it's something I'm wondering about, thanks for the suggestion, I'm going to implement it
Dave

Winfried Jacobs-2 wrote
Hello Dave,

with a little extra method in JSObject (*) you could even write it completely in
Smalltalk:

   html anchor
       onClick: (
           (html jQuery id: 'textAreaId') value: (
               html jQuery id: 'textAreaId') value + 'some text'
               );
       with: 'a label'.


(*) Method #+ in JSObject defined like this:

+ anObject
    "Combine the receiver and anObject with a plus sign"

    self addDecoration: (JSBinary new operator: '+'; statement: anObject)


Best regards
Winfried