Creating Alert Messages with Bootstrap
Set flash data in your controller
$this->session->set_flashdata('alert-danger', 'Invalid Log In');
$this->session->set_flashdata('alert-success', 'Success Log In');
View dynamic dialog message with simple helper function
echo flash_alert();
Helper function :
f(!function_exists('flash_alert')) {
function flash_alert(){
$CI = & get_instance();
$flash_data = $CI->session->flashdata();
$alertMsg = "";
if(empty($flash_data)) {
return $alertMsg;
}
foreach($flash_data as $key => $message) {
$alertMsg.= '<div class="alert '.$key.' fade in">
<a href="#" class="close" data-dismiss="alert">×</a>
'.$message.'
</div>';
}
return $alertMsg;
}
}
$this->session->set_flashdata('alert-danger', 'Invalid Log In');
$this->session->set_flashdata('alert-success', 'Success Log In');
View dynamic dialog message with simple helper function
echo flash_alert();
Helper function :
f(!function_exists('flash_alert')) {
function flash_alert(){
$CI = & get_instance();
$flash_data = $CI->session->flashdata();
$alertMsg = "";
if(empty($flash_data)) {
return $alertMsg;
}
foreach($flash_data as $key => $message) {
$alertMsg.= '<div class="alert '.$key.' fade in">
<a href="#" class="close" data-dismiss="alert">×</a>
'.$message.'
</div>';
}
return $alertMsg;
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.