calling custom javascript functions

72 views
Skip to first unread message

jonas

unread,
Jan 11, 2014, 6:36:43 PM1/11/14
to web...@googlegroups.com
hi

I have developed javascript functions in /static/js/custom/charts.js

they are loaded in layout.html:

 <script src="{{=URL('static','js/custom/charts.js')}}"></script>

I call them in index.html by:

<script>

myfunction();

</script>

I know that ajax and jQuery can be used to call python functions in default.py and my question is, is it possible to use ajax or jQuery to call my custom javascript functions? which one should I use?
My goal is to call d3js functions to generate graphs.

thanks

Massimo Di Pierro

unread,
Jan 11, 2014, 9:50:39 PM1/11/14
to web...@googlegroups.com
I suggest jQuery.ajax

Anthony

unread,
Jan 11, 2014, 10:41:45 PM1/11/14
to web...@googlegroups.com
It's not quite clear what you want to do. You wouldn't use ajax to call a JavaScript function. If you want to call a JS function in the browser, just make sure it is loaded on the page and call it.

Anthony

Jonas Fredriksson

unread,
Jan 12, 2014, 3:48:48 AM1/12/14
to web...@googlegroups.com
I just wanted to see if it's possible to call custom made js functions using jQuery. I found that it is possible to call by using this function:

  $(document).ready(function() {
  $(function_call());
}

css tags can also be added.

but it is simpler to just use myfunction();

In the web2py book all examples covers jQery effects but I couldn't find any information about calling custom made js functions.



On Sun, Jan 12, 2014 at 4:41 AM, Anthony <abas...@gmail.com> wrote:
It's not quite clear what you want to do. You wouldn't use ajax to call a JavaScript function. If you want to call a JS function in the browser, just make sure it is loaded on the page and call it.

Anthony

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/rinBxmv6diM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Anthony

unread,
Jan 12, 2014, 9:08:24 AM1/12/14
to web...@googlegroups.com
Did you try:

$(document).ready(function() {
  myfunction
();
});

Anthony

Jonas Fredriksson

unread,
Jan 12, 2014, 9:57:54 AM1/12/14
to web...@googlegroups.com
yes, and it works. thanks
Reply all
Reply to author
Forward
0 new messages