forked from orbit-oss/flask
Merge pull request #4190 from yuxiaoy1/docs
Improve code example of api & jQuery docs
This commit is contained in:
commit
a0afb6f375
2 changed files with 4 additions and 5 deletions
|
|
@ -256,7 +256,7 @@ the filter to render data inside ``<script>`` tags.
|
||||||
|
|
||||||
.. sourcecode:: html+jinja
|
.. sourcecode:: html+jinja
|
||||||
|
|
||||||
<script type=text/javascript>
|
<script>
|
||||||
const names = {{ names|tosjon }};
|
const names = {{ names|tosjon }};
|
||||||
renderChart(names, {{ axis_data|tojson }});
|
renderChart(names, {{ axis_data|tojson }});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ to add a script statement to the bottom of your ``<body>`` to load jQuery:
|
||||||
|
|
||||||
.. sourcecode:: html
|
.. sourcecode:: html
|
||||||
|
|
||||||
<script type=text/javascript src="{{
|
<script src="{{ url_for('static', filename='jquery.js') }}"></script>
|
||||||
url_for('static', filename='jquery.js') }}"></script>
|
|
||||||
|
|
||||||
Another method is using Google's `AJAX Libraries API
|
Another method is using Google's `AJAX Libraries API
|
||||||
<https://developers.google.com/speed/libraries/>`_ to load jQuery:
|
<https://developers.google.com/speed/libraries/>`_ to load jQuery:
|
||||||
|
|
@ -59,7 +58,7 @@ like this:
|
||||||
|
|
||||||
.. sourcecode:: html+jinja
|
.. sourcecode:: html+jinja
|
||||||
|
|
||||||
<script type=text/javascript>
|
<script>
|
||||||
$SCRIPT_ROOT = {{ request.script_root|tojson }};
|
$SCRIPT_ROOT = {{ request.script_root|tojson }};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -109,7 +108,7 @@ usually a better idea to have that in a separate script file:
|
||||||
|
|
||||||
.. sourcecode:: html
|
.. sourcecode:: html
|
||||||
|
|
||||||
<script type=text/javascript>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$('a#calculate').bind('click', function() {
|
$('a#calculate').bind('click', function() {
|
||||||
$.getJSON($SCRIPT_ROOT + '/_add_numbers', {
|
$.getJSON($SCRIPT_ROOT + '/_add_numbers', {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue