javascript - Using jQuery noty within CodeIgniter view for flashdata (page reload) -


i have been searching ages no avail. trying use jquery noty in order give failure notifications (instead of standard bootstrap notifications have been using). cannot life of me how supposed work. want notification appear based on there being error in flashdata...

i still in learning stages of javascript / jquery dumb newbie mistake, appreciate assistance can rendered!

controller:

elseif ($usr_result['status'] == false) {     $this->session->set_flashdata('flasherror', 'user not active, please contact administrator');     redirect('account/login'); } 

view:

<?if($this->session->flashdata('flasherror')):?>     <script type="text/javascript">         $.noty.defaults.killer = true;          noty({             text: '<?=$this->session->flashdata('flasherror')?>',             layout: 'top',             type: 'error',             closebutton: ['true']});      </script>  <?endif?> 

i have tested noty pressbutton:

<button class="btn btn-primary noty" data-noty-options='{"text":"this alert","layout":"top","type":"alert","closebutton":"true"}'><i class="halflings-icon white bell"></i> bottom full width close button</button> 

and works fine (so jquery , noty both loaded correctly)

i'm not sure if best way achieve it, after researching javascript (theres near enough documentation on noty anywhere near helpful isn't javascript pro), ended doing in view work:

<?if($this->session->flashdata('flasherror')):?> <script type="text/javascript">     function notify() {         noty({             text: '<?=$this->session->flashdata('flasherror')?>',             layout: 'top',             type: 'error',             closebutton: true,             timeout: false         });     }     window.onload = notify; </script> <?endif?> 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -