Skip to content

Instantly share code, notes, and snippets.

@db0company
Created February 14, 2013 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save db0company/4954780 to your computer and use it in GitHub Desktop.
Save db0company/4954780 to your computer and use it in GitHub Desktop.
JQuery test with Ocsigen
(* ************************************************************************** *)
(* 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