Reputation: 344
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?
Upvotes: 2
Views: 1222
Reputation: 25536
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>
Upvotes: 3