aozora aozora - 9 months ago 48
Javascript Question

How to use Laravel commands inside Bootstrap modal?

I have a textbox that upon click opens a Bootstrap modal while passing a number with it.

However when I am in the modal content page, I can't use any Laravel 4.2 functions.

How can I display a page from Laravel to modal. I am fine in making views or new models.

My main html looks like this:

<input type='text' value='EDIT ENTRY' onclick="callModalLotEdit(1);">
<!-- Modals -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">

Then my Javascript function:

function callModalLotEntry(ID){
$.ajax( {
type: "POST",
url: "../app/views/ajaxmodal.blade.php",
data: "ID=ID",
success: function(result){
} );

When I am in ajaxmodal.blade.php I have no access to Laravel functions.


Create a route and return the view

Route::post('ajaxmodal', function(){
return View::make('ajaxmodal');

ajax to that view

 url: "{{url('ajaxmodal')}}",