Getting Lasso Variable into JavaScript

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

Getting Lasso Variable into JavaScript

Stanley Weber
Hi all,

I have read the many postings regarding how to get a Lasso variable
into JavaScript on the Lasso Talk list, but again, I cannot find an
answer.

I have the javascript in the header, but one of the points made in
previous answers to this question is that "Lasso is processed by the
server (before it's sent to the browser), while javascript is done on
the browser, after Lasso is finished with it." So it seems to me that
the Lasso variable ought to be available to the javascript in the
header. Perhaps I am wrong.

I am trying to us the jQuery ui.slider to input data and, with Jason
Huck's help yesterday, I got much of it working. Now I would like to
use the "moveTo" function of the slider to display an already moved
slider handle if data exists in my database.

I can get the slide to move successfully using the following:

    $('#slider1').slider('moveTo',50);

But trying many different variations on the escaping the brackets,
and using parentheses, etc., I cannot get something like the
following to work:

    $('#slider1').slider('moveTo',[Var: 'ExistingValue']);

The variable ExistingValue does exist, but again, it gets assigned in
the body of the page, not the header if that makes any difference.

Thanks for any help!
--
||||||||||||||||||||||||||||||||||||||||||
Stanley S. Weber, Pharm.D., FASHP, BCPP
Associate Dean for Professional Pharmacy Education
University of Washington
PO Box 357631
Seattle, Washington 98195-7631

[hidden email]
(206) 616-8762 (voice)
(206) 685-9297 (fax)


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: Getting Lasso Variable into JavaScript

jasonhuck
There could be several issues. A few pointers:

- Use "View Source" in your web browser to see what's actually being
sent. If the rendered source still shows [Var: 'whatever'] then Lasso
didn't process the variable. If it shows the value instead, then it's
a JavaScript issue. You can use the JavaScript console or a debugger
such as Firebug to get more specific information.

- Lasso won't parse anything between HTML comments, so make sure your
JavaScript isn't surrounded by those -- at least the part where you
want to use Lasso variables. If your JavaScript actually contains
square brackets (for working with arrays), you'll need to keep that
part surrounded by HTML comments or output the brackets using Lasso,
i.e. ['['] and [']'].

- It doesn't matter where in the document the Lasso variable is
defined as long as it's before you try to use it (in other words,
higher up on the page).

HTH,
Jason


On Sun, Aug 3, 2008 at 1:15 PM, Stanley Weber <[hidden email]> wrote:

> Hi all,
>
> I have read the many postings regarding how to get a Lasso variable into
> JavaScript on the Lasso Talk list, but again, I cannot find an answer.
>
> I have the javascript in the header, but one of the points made in previous
> answers to this question is that "Lasso is processed by the server (before
> it's sent to the browser), while javascript is done on the browser, after
> Lasso is finished with it." So it seems to me that the Lasso variable ought
> to be available to the javascript in the header. Perhaps I am wrong.
>
> I am trying to us the jQuery ui.slider to input data and, with Jason Huck's
> help yesterday, I got much of it working. Now I would like to use the
> "moveTo" function of the slider to display an already moved slider handle if
> data exists in my database.
>
> I can get the slide to move successfully using the following:
>
>   $('#slider1').slider('moveTo',50);
>
> But trying many different variations on the escaping the brackets, and using
> parentheses, etc., I cannot get something like the following to work:
>
>   $('#slider1').slider('moveTo',[Var: 'ExistingValue']);
>
> The variable ExistingValue does exist, but again, it gets assigned in the
> body of the page, not the header if that makes any difference.
>
> Thanks for any help!
> --
> ||||||||||||||||||||||||||||||||||||||||||
> Stanley S. Weber, Pharm.D., FASHP, BCPP
> Associate Dean for Professional Pharmacy Education
> University of Washington
> PO Box 357631
> Seattle, Washington 98195-7631
>
> [hidden email]
> (206) 616-8762 (voice)
> (206) 685-9297 (fax)
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>



--
tagSwap.net :: Open Source Lasso Code
<http://tagSwap.net/>

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: Getting Lasso Variable into JavaScript

Tim Taplin
In reply to this post by Stanley Weber
just a few thoughts as you are on the right track and should be able  
to accomplish this.

Make sure that the javascript where you are inserting [var:  
'ExistingValue'] is in the response page where the value was an  
action param and you have already converted that action_param to a  
variable.  as long as the function slider('moveTo', value) doesn't  
require ' ' around the value and the above requirements are met, you  
should be in business.  One of the debug methods I use would be to  
insert an
        alert(' [var: 'ExistingValue'] ');
       
        above and below the line

         $('#slider1').slider('moveTo',[Var: 'ExistingValue']);

so that you can really see what value your var had at that time in  
the script execution.

if the alert below doesnt come up then the function failed without  
providing appropriate error message which is not unusual with  
javascript functions. I'm sure there is a logical reason relating to  
scope or layering or something but its just a truth. However, at  
least you'll know what the value appeared as before the function call  
and can check your docs and code and work forward.

I've found that Parentheses syntax is easier to work with Javascript-
lasso solutions for mostly visual reasons. so I would write the var  
as [var('ExistingValue')]

Hope that helps.

Tim Taplin



On Aug 3, 2008, at 11:15 AM, Stanley Weber wrote:

> Hi all,
>
> I have read the many postings regarding how to get a Lasso variable  
> into JavaScript on the Lasso Talk list, but again, I cannot find an  
> answer.
>
> I have the javascript in the header, but one of the points made in  
> previous answers to this question is that "Lasso is processed by  
> the server (before it's sent to the browser), while javascript is  
> done on the browser, after Lasso is finished with it." So it seems  
> to me that the Lasso variable ought to be available to the  
> javascript in the header. Perhaps I am wrong.
>
> I am trying to us the jQuery ui.slider to input data and, with  
> Jason Huck's help yesterday, I got much of it working. Now I would  
> like to use the "moveTo" function of the slider to display an  
> already moved slider handle if data exists in my database.
>
> I can get the slide to move successfully using the following:
>
>    $('#slider1').slider('moveTo',50);
>
> But trying many different variations on the escaping the brackets,  
> and using parentheses, etc., I cannot get something like the  
> following to work:
>
>    $('#slider1').slider('moveTo',[Var: 'ExistingValue']);
>
> The variable ExistingValue does exist, but again, it gets assigned  
> in the body of the page, not the header if that makes any difference.
>
> Thanks for any help!
> --
> ||||||||||||||||||||||||||||||||||||||||||
> Stanley S. Weber, Pharm.D., FASHP, BCPP
> Associate Dean for Professional Pharmacy Education
> University of Washington
> PO Box 357631
> Seattle, Washington 98195-7631
>
> [hidden email]
> (206) 616-8762 (voice)
> (206) 685-9297 (fax)
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: Getting Lasso Variable into JavaScript (working)

Stanley Weber
Thanks Jason and Tim

I just wanted to let you know that your suggestions worked. The line
of code I indicated in my question below as not working, actually
does work! So this does work:

    $('#slider1').slider('moveTo',[Var: 'ExistingValue']); so does this:
    $('#slider1').slider('moveTo',[Field: 'ExistingValue']);

The thing I did change was to move the javascript containing the
above line from the html header to the body after the inline was
called. So I am not sure what it means that "Lasso is processed by
the server (before it's sent to the browser), while javascript is
done on the browser, after Lasso is finished with it." I would have
thought the fields and variables would be available through Lasso
before javascript processes it.

Anyway thanks again for your help to get it working!

Stan


At 3:16 PM -0600 8/3/08, Tim Taplin wrote:

>just a few thoughts as you are on the right track and should be able
>to accomplish this.
>
>Make sure that the javascript where you are inserting [var:
>'ExistingValue'] is in the response page where the value was an
>action param and you have already converted that action_param to a
>variable.  as long as the function slider('moveTo', value) doesn't
>require ' ' around the value and the above requirements are met, you
>should be in business.  One of the debug methods I use would be to
>insert an
> alert(' [var: 'ExistingValue'] ');
>
> above and below the line
>
> $('#slider1').slider('moveTo',[Var: 'ExistingValue']);
>
>so that you can really see what value your var had at that time in
>the script execution.
>
>if the alert below doesnt come up then the function failed without
>providing appropriate error message which is not unusual with
>javascript functions. I'm sure there is a logical reason relating to
>scope or layering or something but its just a truth. However, at
>least you'll know what the value appeared as before the function
>call and can check your docs and code and work forward.
>
>I've found that Parentheses syntax is easier to work with
>Javascript-lasso solutions for mostly visual reasons. so I would
>write the var as [var('ExistingValue')]
>
>Hope that helps.
>
>Tim Taplin
>
>
>
>On Aug 3, 2008, at 11:15 AM, Stanley Weber wrote:
>
>>Hi all,
>>
>>I have read the many postings regarding how to get a Lasso variable
>>into JavaScript on the Lasso Talk list, but again, I cannot find an
>>answer.
>>
>>I have the javascript in the header, but one of the points made in
>>previous answers to this question is that "Lasso is processed by
>>the server (before it's sent to the browser), while javascript is
>>done on the browser, after Lasso is finished with it." So it seems
>>to me that the Lasso variable ought to be available to the
>>javascript in the header. Perhaps I am wrong.
>>
>>I am trying to us the jQuery ui.slider to input data and, with
>>Jason Huck's help yesterday, I got much of it working. Now I would
>>like to use the "moveTo" function of the slider to display an
>>already moved slider handle if data exists in my database.
>>
>>I can get the slide to move successfully using the following:
>>
>>    $('#slider1').slider('moveTo',50);
>>
>>But trying many different variations on the escaping the brackets,
>>and using parentheses, etc., I cannot get something like the
>>following to work:
>>
>>    $('#slider1').slider('moveTo',[Var: 'ExistingValue']);
>>
>>The variable ExistingValue does exist, but again, it gets assigned
>>in the body of the page, not the header if that makes any
>>difference.
>>
>>Thanks for any help!
>>--
>>||||||||||||||||||||||||||||||||||||||||||
>>Stanley S. Weber, Pharm.D., FASHP, BCPP
>>Associate Dean for Professional Pharmacy Education
>>University of Washington
>>PO Box 357631
>>Seattle, Washington 98195-7631
>>
>>[hidden email]
>>(206) 616-8762 (voice)
>>(206) 685-9297 (fax)
>>
>>
>>--
>>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>>Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>
>
>--
>This list is a free service of LassoSoft: http://www.LassoSoft.com/
>Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>Manage your subscription: http://www.ListSearch.com/Lasso/


--
||||||||||||||||||||||||||||||||||||||||||
Stanley S. Weber, Pharm.D., FASHP, BCPP
Associate Dean for Professional Pharmacy Education
University of Washington
PO Box 357631
Seattle, Washington 98195-7631

[hidden email]
(206) 616-8762 (voice)
(206) 685-9297 (fax)


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/