I'm injecting a component into my web2py page using {{=LOAD(...)}}
as described at http://web2py.com/books/default/chapter/29/12/components-and-plugins#LOAD, but I need to fire off some javascript once the component is loaded. Normally if something is loaded via ajax, there is a success callback. How can I set one of this via {{=LOAD(...)}}
in web2py?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- Using :remote => true with hover event
- Is there a way to play audio on a mobile browser w
- net::ERR_EMPTY_RESPONSE when post with ajax
- Easiest way to get json and parse it using JQuery
相关文章
- spring boot用ajax发送请求后,请求路径多了controller的路径
- 针对复杂结构的前端页面,如何更好地与后台交互实现动态网页?
- ajax上传图片,偶尔会出现后台保存的图片有错误或者已损坏,请问可能是什么原因造成的?
- 前端 我想知道怎样通过发ajax请求向服务器拿到数据然后分页显示 最好是点击一页就发一次请求
- 接口返回的数据格式如下,请问可以取到level值为2的name数组呢
- 如何通过页面输入账号密码提交给后端
- How to get jQuery.ajax response status?
- How to read local csv file in client side javascri
The simplest approach would be to set
response.js
in the controller of the component:Alternatively, you could simply include a
<script>
tag directly in the component itself, which will execute when the component is loaded.Finally, whenever a web2py Ajax call completes, an
ajax:complete
event is fired. So, you could set up an event handler and check whether the Ajax response is a component:Note that the presence of the
web2py-component-content
header indicates that the Ajax response is a component.The only downside of this last approach is that the event handler will be triggered before the content of the component is added to the DOM, so if the event handler takes long to run, it may noticeably delay the appearance of the component content.