Created
February 14, 2013 18:04
-
-
Save db0company/4954780 to your computer and use it in GitHub Desktop.
JQuery test with Ocsigen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* ************************************************************************** *) | |
(* Project: Ocsigen Quick Howto : Javascript Inclusion *) | |
(* Description: Example of a page including external javascript script *) | |
(* Author: db0 (db0company@gmail.com, http://db0.fr/) *) | |
(* Latest Version is on GitHub: http://goo.gl/sfvvq *) | |
(* ************************************************************************** *) | |
open Eliom_content | |
open Html5.D | |
open Eliom_parameter | |
(* ************************************************************************** *) | |
(* Application *) | |
(* ************************************************************************** *) | |
module Example = | |
Eliom_registration.App | |
(struct | |
let application_name = "example" | |
end) | |
(* ************************************************************************** *) | |
(* Service declaration *) | |
(* ************************************************************************** *) | |
let main = | |
Eliom_service.service | |
~path:[] | |
~get_params:unit | |
() | |
(* ************************************************************************** *) | |
(* Service definition *) | |
(* ************************************************************************** *) | |
let _ = | |
Example.register | |
~service:main | |
(fun () () -> | |
let hidden_div = | |
div ~a:[a_class ["toggled"]] [pcdata "Hello, yes, this is dog!"] in | |
let clickable_div = | |
div ~a:[a_class ["button"]; | |
a_onclick {{ | |
let js_hidden_div = Eliom_content.Html5.To_dom.of_div %hidden_div in | |
js_hidden_div##slideToggle(Js.string "fast") | |
}}] | |
[pcdata "Click me!"] in | |
Lwt.return | |
(html | |
(head (title (pcdata "Hello World of Ocsigen")) | |
[js_script ~uri:(make_uri (Eliom_service.static_dir ()) | |
["jquery.js"]) ()]) | |
(body [clickable_div; | |
hidden_div]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment