Putting a javascript variable in a JQuery ID

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

Putting a javascript variable in a JQuery ID

Dave
Hi there
I have to read a javascript variable (myResultingID), this is the script:

html
                html:
'<script> ... var myResultingID = ''result''.concat(nextId); ... </script>'



and I have to use it as a JQuery id, but if I write: html jQuery id: 'myResultingID', Seaside generates $('#myResultingID') see:

html
                html:
'<script> ..., ((html jQuery ajax callback: [ ... ] value: ...; onSuccess: ((html jQuery id: 'myResultingID') load html: [ :h | self renderMyValuesOn: h ])) greaseString ,... </script>'




So I found an ugly solution i.e. replacing the Seaside generated string with the javascript right concatenation, see here:


html
                html:
'<script> ..., ((html jQuery ajax callback: [ ... ] value: ...; onSuccess: ((html jQuery id: 'myResultingID') load html: [ :h | self renderMyValuesOn: h ])) greaseString copyReplaceAll: '"#myResultingID"' with: '"#"+myResultingID') ,... </script>'

Is there a better way?
Thanks

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Putting a javascript variable in a JQuery ID

Paul DeBruicker
I think the #expression: method will do what you want.  


e.g.

html jQuery expression: 'myResultingId'





Dave wrote
Hi there
I have to read a javascript variable (myResultingID), this is the script:

html
                html:
'<script> ... var myResultingID = ''result''.concat(nextId); ... </script>'



and I have to use it as a JQuery id, but if I write: html jQuery id: 'myResultingID', Seaside generates $('#myResultingID') see:

html
                html:
'<script> ..., ((html jQuery ajax callback: [ ... ] value: ...; onSuccess: ((html jQuery id: 'myResultingID') load html: [ :h | self renderMyValuesOn: h ])) greaseString ,... </script>'




So I found an ugly solution i.e. replacing the Seaside generated string with the javascript right concatenation, see here:


html
                html:
'<script> ..., ((html jQuery ajax callback: [ ... ] value: ...; onSuccess: ((html jQuery id: 'myResultingID') load html: [ :h | self renderMyValuesOn: h ])) greaseString copyReplaceAll: '"#myResultingID"' with: '"#"+myResultingID') ,... </script>'

Is there a better way?
Thanks

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Putting a javascript variable in a JQuery ID

Johan Brichau-2
Perhaps:

html jQuery expression: (html javascript alias: ‘myResultingId’)

cheers
Johan

ps: I don’t see any text of your examples (copy/paste error?)

On 18 Jul 2016, at 16:57, Paul DeBruicker <[hidden email]> wrote:

I think the #expression: method will do what you want.  


e.g.

html jQuery expression: 'myResultingId' 






Dave wrote
Hi there
I have to read a javascript variable (myResultingID), this is the script:

html
html:
'

'



and I have to use it as a JQuery id, but if I write: html jQuery id:
'myResultingID', Seaside generates $('#myResultingID') see: 

html
html:
'

'




So I found an ugly solution i.e. replacing the Seaside generated string
with the javascript right concatenation, see here:


html
html:
'

'

Is there a better way?
Thanks

Dave





--
View this message in context: http://forum.world.st/Putting-a-javascript-variable-in-a-JQuery-ID-tp4906951p4906962.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: Putting a javascript variable in a JQuery ID

Dave
Thanks Johan, it works.

cheers
Dave

Johan Brichau-2 wrote
Perhaps:

html jQuery expression: (html javascript alias: ‘myResultingId’)

cheers
Johan

ps: I don’t see any text of your examples (copy/paste error?)

> On 18 Jul 2016, at 16:57, Paul DeBruicker <[hidden email]> wrote:
>
> I think the #expression: method will do what you want.  
>
>
> e.g.
>
> html jQuery expression: 'myResultingId'
>
>
>
>
>
>
> Dave wrote
>> Hi there
>> I have to read a javascript variable (myResultingID), this is the script:
>>
>> html
>> html:
>> '
>
>> '
>>
>>
>>
>> and I have to use it as a JQuery id, but if I write: html jQuery id:
>> 'myResultingID', Seaside generates $('#myResultingID') see:
>>
>> html
>> html:
>> '
>
>> '
>>
>>
>>
>>
>> So I found an ugly solution i.e. replacing the Seaside generated string
>> with the javascript right concatenation, see here:
>>
>>
>> html
>> html:
>> '
>
>> '
>>
>> Is there a better way?
>> Thanks
>>
>> Dave
>
>
>
>
>
> --
> View this message in context: http://forum.world.st/Putting-a-javascript-variable-in-a-JQuery-ID-tp4906951p4906962.html <http://forum.world.st/Putting-a-javascript-variable-in-a-JQuery-ID-tp4906951p4906962.html>
> Sent from the Seaside General mailing list archive at Nabble.com <http://nabble.com/>.
> _______________________________________________
> seaside mailing list
> [hidden email] <mailto:[hidden email]>
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside <http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside>

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