0

Can I call a javascript function in model of codeigniter?

I made a modal in my view..

<div class="modal fade" id="success" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-haspopup="true" aria-hidden="true">
    <div class="modal-dialog">
         <div class="modal-content">
              <div class="alert alert-success fade in" id="alert">
                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                 <h4>Success!</h4>
                 <p>Record successfully deleted.</p>
                 <a id="okButton" class="btn btn-success" data-dismiss="modal">
                     OK 
                 </a>
               </div>     
          </div>
     </div>

and in my model

public function delete_job_title($P1)
{
   if (success condition)
   {
      what could should i put in here to call the function in javascript? or to show the modal?
   }
}

I don't know what to put in there in order to show the modal?. whereas in jquery you can show it by:

" $('#success').modal('show'); "

but I want to call it in my model.

My main question is there a way to call a function in javascript from a model of codeigniter?

whereas in my javascript:

function showsuccess()
{
$('#success').modal('show');
}
4

2 回答 2

0

你可以这样做。

<input type='button' name='show_model' class='modal_display'>

jQuery

$(function(){
    $('.modal_display').click(function(){
         $('.modal-content').load('controller/method');
    });
});
于 2013-10-02T05:33:42.650 回答
0

只有控制器可以与 javascript/ajax 交互

于 2019-08-06T10:28:08.143 回答