summaryrefslogtreecommitdiff
path: root/addons/web_api
diff options
context:
space:
mode:
authorAntony Lesuisse <al@openerp.com>2012-08-30 14:43:37 +0200
committerAntony Lesuisse <al@openerp.com>2012-08-30 14:43:37 +0200
commit01e5824fb0f0bfc9f81c8833861aee1fc891bbfa (patch)
tree0051f518b24d05625f1f15de8ee6927205509363 /addons/web_api
parent19f2f726622a930891acc3c6ef0df54e2112b97f (diff)
[IMP] web_api improve example
bzr revid: al@openerp.com-20120830124337-4uraforhvgv18tff
Diffstat (limited to 'addons/web_api')
-rw-r--r--addons/web_api/static/src/example.html38
1 files changed, 17 insertions, 21 deletions
diff --git a/addons/web_api/static/src/example.html b/addons/web_api/static/src/example.html
index 9c920e31fa2..5408b1de36c 100644
--- a/addons/web_api/static/src/example.html
+++ b/addons/web_api/static/src/example.html
@@ -18,38 +18,34 @@
<script type="text/javascript">
$(function() {
$("body").on('click','button',function(ev){
- eval($("pre.run").text());
+ console.log($("textarea").val());
+ eval($("textarea").val());
});
});
</script>
</head>
<body>
- <h1>OpenERP web_api examples</h1>
- <h2>Example 1: Load the list of defined ir.model <button>Run it !</button></h2>
- <blockquote>
- <h3>Code: </h3>
+ <h1>OpenERP web_api test</h1>
+ <h2>Example: Load the content of ir.model <button>Run it !</button></h2>
<pre>
&lt;script type="text/javascript" src="/web/webclient/js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
-<pre id="ex1" class="run">
- var instance = openerp.init(["web"]); // get a new instance
- instance.session.session_bind(); // bind it to the right hostname
- instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
- var ds = new instance.web.DataSetSearch(null, "ir.model");
- ds.read_slice(['name','model'], {}).then(function(models){
- _.each(models,function(m,i){
- $("#ex1res").append("&lt;li&gt;" + m.model + " (" + m.name + ") &lt;/li&gt;")
- });
+<textarea rows="12" cols="100"id="ex1" class="run">
+var instance = openerp.init(["web"]); // get a new instance
+instance.session.session_bind(); // bind it to the right hostname
+instance.session.session_authenticate("trunk", "admin", "admin", false).then(function() {
+ var ds = new instance.web.DataSetSearch(null, "ir.model");
+ ds.read_slice(['name','model'], {}).then(function(models){
+ _.each(models,function(m,i){
+ $("#result").append("&lt;li&gt;" + m.model + " (" + m.name + ") &lt;/li&gt;")
});
});
-</pre>&lt;/script&gt;
+});
+</textarea>
+&lt;/script&gt;</pre>
+ <h3>Result:</h3>
+ <pre id="result" class="result">
</pre>
- <h3>Div for output:</h3>
- <div id="ex1res" class="result">
- &nbsp;
- </div>
- </blockquote>
- <h2>Help me to complete this examples on <a href="http://bazaar.launchpad.net/~openerp/openerp-web/trunk/view/head:/addons/web_api/static/src/example.html">launchpad</a></h2>
</body>
</html>