CloServe A view first web framework in Clojure

Send Javascript to Client

Send Javascript to Client

WIth Snippet code, we can send javascript code dynamically to browser to execute.

Let's use the form.ajax call back function to send a simple piece of js to browser:

 [context cmd]
 (send-cmd-to-page (:page-id context)
                   {:act :globalEval
                    :code "alert('Alert from Server!');"}))

The corresponding HTML code:

<form class="input-group lift:form.ajax?callback=MakeAlert">
       <input name="ppp" type="hidden" class="">
       <span class="input-group-btn">
         <input value="Send me an alert!" class="btn btn-default" type="submit">

Try it here: