// Form input elements disabled during form submission
disableSelector: 'input, button, textarea, select',
// Form input elements re-enabled after form submission
enableSelector: 'input:disabled, button:disabled, textarea:disabled, select:disabled',
$('#note-form').submit(function(e) {
e.preventDefault();
$form= $(this);
$.post("/app/controller/action.json",
{formdata: $form.serialize(),
note_id: $('#note-id').val(),
note_text: $('#note-text').val()
},
function(data) {
$('#form-feedback').html(data.notes).fadeIn(500);
$form[0].reset();
}
);
});
def display_page():
return dict(foo='bar')
def return_data():
data= {'foo':'text processed: %s' % request.vars.formdata}
return data
{{extend 'layout.html'}}
<script>
$(document).ready(function() {
$('#note-btn').click(function() {
$('#note-modal').modal({
show: true
});
});
$('#note-form').submit(function(e) {
e.preventDefault();
$form= $(this);
$.post('{{=URL('default', 'return_data.json')}}',
{formdata: $form.serialize()},
function(data) {$('#form-feedback').html(data.foo);}
);
});
});
</script>
<a href="#" id="note-btn">Open modal</a>
<div id="note-modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<form class="form-horizontal" id="note-form">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">×</span><span class="sr-only">Close</span>
</button>
<h4 class="modal-title">Enter Notes</h4>
<div class='bg-success text-center' id='form-feedback'></div>
</div>
<div class="modal-body">
<div class="form-group">
<div>
<textarea class="form-control" id="note-text" name="note_text"></textarea>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-default" data-dismiss="modal">Close</a>
<button type="submit" class="btn btn-primary">Save Notes</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<input type="button" class="submit-button" id="something_created_server_side">
return false;
{{extend 'layout.html'}}
<div id="target"></div>
<form id="myform">
<input name="your_message" id="your_message" />
<input type="submit" />
</form>
<script>
jQuery('#myform').submit(function() {
ajax('{{=URL('new_post')}}',
['your_message'], 'target');
//return false;
});
</script>
I'm sorry I wasn't testing any of this. Have a working example attached.
--
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/BfKNToXlKds/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/d/optout.