web2py组件

编程入门 行业动态 更新时间:2024-10-25 10:30:44
本文介绍了web2py组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在同一视图中加载不同的web2py组件,但不能同时加载.我有5个.load文件,这些文件具有针对不同情况的表单字段,这些文件由onchange选择脚本动态调用.使用web2py可以做到这一点吗?

I would like to load different web2py components in the same view, but not at the same time. I have 5 .load files which have form fields for a different scenario, these are called dynamically by an onchange select script. Is it possible with web2py to do this?

推荐答案

是的,但是在那种情况下,请不要在web2py视图中使用LOAD()帮助程序,因为这会生成Javascript,该Javascript会在页面上立即加载组件加载.相反,创建一个具有ID的div来容纳组件,并让您的onchange事件处理程序以div的id为目标调用web2py_component()函数:

Yes, but in that case, don't use the LOAD() helper in the web2py view, as that will generate Javascript that loads the component immediately upon page load. Instead, create a div with an id to hold the component, and have your onchange event handler call the web2py_component() function with the id of the div as the target:

<div id='mycomponent'></div> <script> $(function() { $('some_selector').change(function() { web2py_component('{{=URL('default', 'mycomponent')}}', target='mycomponent'); }); }); </script>

更多推荐

web2py组件

本文发布于:2023-10-23 14:08:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1521051.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组件   web2py

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!