I am a beginner in Twitter Bootstrap and I am trying to process a form from a modal box, which is also loaded with Ajax. The problem is that I don't know how to use it. I have searched on google for hours, but I couldn't find a good example.
I have used jquery ui before and I guess it might be almost the same. I would like to know the following:
I will appreciate the help and I can provide a form sample below:
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Submit a link</h3>
</div>
<div class="modal-body">
<div id="msgholder1"></div>
<div id="msg-loader"></div>
<form action="../ajax/controller.php" data-async data-target="#msgholder1" id="add-link-form" method="POST">
<table id="theform">
<tr>
<td>URL:</td>
<td><input type="text" name="url" size="45" class="text ui-widget-content ui-corner-all" id="url" /></td>
</tr>
<tr>
<td>Quality:</td>
<td><select name="quality" id="quality">
<option value="0">Pick One ...</option>
<option value="1">CAM</option>
<option value="2">TS</option>
<option value="3">DVD</option>
</select><br />
</td>
</tr>
<tr>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
Any kind of related documentation is also useful.
Thanks!
After some hours of research and work around, I've got the following working Ajax Modal script:
<script type="text/javascript">
$(document).ready(function() {
$('#addlink').on('click', function(event) {
var href = SITEURL + '/modules/movies/addlink.tpl.php?movie_id=<?php echo $movie->id; ?>';
$.get(href, function(response) {
$('.modal').html(response);
$('.modal').modal({keyboard:true});
$('button#submit_link').bind('click', function()
{
$('.modal-body').html('<p>Loading ...</p>');
$.ajax({
type: 'post',
url: SITEURL + "/ajax/controller.php",
data: 'action=report_link',
dataType : 'html',
context: $(this),
success: function (msg) {
$(".modal-body").html(msg);
}
});
});
});
event.preventDefault();
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With