how can I use result of onLoad() javascript function in session or view

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

how can I use result of onLoad() javascript function in session or view

Sabine Manaa
Hi,

short version of my question:

how can I use the result of a javascript function which is called onLoad within my smalltalk code? Eg. set the result in an inst var of view or session?

Long version/explanation:

I want to render different html date widgets depending on the browser support.
Exactly, I want to render html5 input types if the browser supports them.
http://www.hongkiat.com/blog/html5-form-input-type/

If not (many browsers do not support them), I will use my existing JQuery datepicker solution.

Background is, that for mobile, I want to use the html5 widgets, where you can use scroll wheels to select dates and not the jquery calendar.

For this, I have a Javascript function which is called onLoad (later possibly modernizr).
It works, it returns true if html5 date widget is supported and false if it is not supported.

'function detectHtmlDate5 () {
var i = document.createElement("input");
i.setAttribute("type", "date");
return i.type == "date";
};
'
(http://diveintohtml5.info/detect.html#input-types)

I call it by adding the js code in the updateRoot:
aHtmlRoot javascript url: theLibraryName / #rkaJs.

and calling it within renderContentOn: of the main view

html document addLoadScript: (html javascript add: (JSStream new
                nextPutAll: 'detectHtmlDate5()';
                yourself)).

This works, because if I add an alert() within the javascript function; the alert shows true or false when loading the page.

But I have no idea how to get the result into my session or my view.

I hope the problem is clear and someone having an answer for me.

Sabine




Reply | Threaded
Open this post in threaded view
|

Re: how can I use result of onLoad() javascript function in session or view

Bob Arning-2
Maybe you don't even need that.

    html div
        onClick: (html jQuery ajax
            callback: [ :var | var halt]
            value: (JSStream on: 'detectHtmlDate5()')
        );
        with: 'testing'.

var is 'true' when I click on this. So, something like this could tell you what to render next. Alternately, the onload code could store the result in a js var which gets returned by the above method when user clicks.

Cheers,
Bob


On 2/3/14 11:00 AM, Sabine Knöfel wrote:
short version of my question:

how can I use the result of a javascript function which is called onLoad
within my smalltalk code? Eg. set the result in an inst var of view or
session?


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

Re: how can I use result of onLoad() javascript function in session or view

Sabine Manaa
Hi Bob,

thank you. This helps. 
I use your code within the login screen and save the result in the session.

Regards
Sabine


On Mon, Feb 3, 2014 at 5:36 PM, Bob Arning-2 [via Smalltalk] <[hidden email]> wrote:
Maybe you don't even need that.

    html div
        onClick: (html jQuery ajax
            callback: [ :var | var halt]
            value: (JSStream on: 'detectHtmlDate5()')
        );
        with: 'testing'.

var is 'true' when I click on this. So, something like this could tell you what to render next. Alternately, the onload code could store the result in a js var which gets returned by the above method when user clicks.

Cheers,
Bob


On 2/3/14 11:00 AM, Sabine Knöfel wrote:
short version of my question:

how can I use the result of a javascript function which is called onLoad
within my smalltalk code? Eg. set the result in an inst var of view or
session?


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



If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/how-can-I-use-result-of-onLoad-javascript-function-in-session-or-view-tp4741219p4741238.html
To start a new topic under Seaside General, email [hidden email]
To unsubscribe from Seaside, click here.
NAML