Commit d0010f8f authored by Ivan Tyagov's avatar Ivan Tyagov

Add support for "data-gadget-source" and "data-gadget-handler".

Add basic example how to use.
parent e44f4e58
<html>
<head>
<script data-main="require-renderjs.js"
type="text/javascript"
src="../../lib/require/require.js"></script>
<head>
<body>
<p>Contained below gadget will get some JSON data from server and update it on page.</p>
<p>It will also load an additional library (using requirejs) that will be used by this gadget.</p>
<div id="json-gadget"
data-gadget=""
data-gadget-source = "json_file.json"
data-gadget-handler="parseJSONAndUpdateDOM"
data-gadget-cacheable="0"
data-gadget-cache-id="json-gadget">
First name: <div id="first_name"></div>
Last name: <div id="last_name"></div>
</div>
</body>
</html>
\ No newline at end of file
{"first_name": "John",
"last_name": "Doh"}
\ No newline at end of file
function parseJSONAndUpdateDOM(result) {
$("#first_name").text(result['first_name']);
$("#last_name").text(result['last_name']);
}
\ No newline at end of file
// JavaScript file that is used to load RenderJs depenencies
require(["../../lib/jquery/jquery.js",
"../../renderjs.js",
"json_gadget.js"
],
function (domReady) {
// Place code to be executed when libraries are loaded
});
...@@ -171,8 +171,12 @@ var RenderJs = (function () { ...@@ -171,8 +171,12 @@ var RenderJs = (function () {
} }
}); });
} }
} else { }
// gadget is an inline one so no need to load it from network else {
// gadget is an inline (InteractorGadget or one using
// data-gadget-source / data-gadget-handler) so no need
// to load it from network
RenderJs.updateGadgetData(gadget);
gadget_js.setReady(); gadget_js.setReady();
RenderJs.checkAndTriggerReady(); RenderJs.checkAndTriggerReady();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment