Disclaimer: I’m new to web development.
I’m creating an event calendar using CodeIgniter, and when I’m updating an event (using js), I need to reload the exact current page that I am on at that moment. So far, all I’ve been able to do is redirect to the main controller containing the calendar class, which brings me back to the current month. This sucks for someone editing one event on a different month other than the current month. Any ideas on what to use/do? Thanks a lot for all of your help!
Controller:
if ($this->events->update($data))
{
redirect('user/planner');
}
else
{
show_404();
}
View/Form:
<div class="reveal-modal" id="myModal">
<?php echo form_open('user/planner/update/'.$event->id, 'id="updateForm"'); ?>
<h3><?php echo $event->type ?></h3>
<h4><label for="status">Status</label></h4>
<p><?php echo form_dropdown('status', $status_options, $event->status ) ?></p>
<h4><label for="title">Title</label></h4>
<p><input type="text" id="title" name="title" value="<?php echo $event->title ?>" /></p>
<h4><label for="content">Content</label></h4>
<p><textarea rows="7" id="content" name="content"><?php echo $event->content ?></textarea></p>
<p><?php echo form_submit('submit','Save') ?></p>
<?php echo form_close(); ?>
</div>
JS That is running form:
$(function() {
$('.event_list li').click( function(e) {
console.log(this.id);
$('#update_view_content').load('http://example.com/user/planner/update/'+this.id,function() {
$('#myModal').reveal();
});
});
$('#updateForm').live('submit', function() {
var data = $('#updateForm').serialize();
var url = $(this).attr('action');
$.post(url, data);
return;
});
});
you should reload document.location as Jan said (
document.location.reload()), but it should be done only when request is success, so your code will be something like this: