Reputation: 421
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">
</div>
</div>
</div>
Then my Javascript function:
function callModalLotEntry(ID){
$.ajax( {
type: "POST",
url: "../app/views/ajaxmodal.blade.php",
data: "ID=ID",
success: function(result){
$('.modal-content').html(result);
$('#myModal').modal().show();
}
} );
}
When I am in ajaxmodal.blade.php I have no access to Laravel functions.
Upvotes: 0
Views: 111
Reputation: 32354
Create a route and return the view
Route::post('ajaxmodal', function(){
return View::make('ajaxmodal');
});
ajax to that view
url: "{{url('ajaxmodal')}}",
Upvotes: 1
Reputation: 26258
You have to make a function in controller that can return a view to ajax call response as a string. Like this:
function callModalLotEntry(ID){
$.ajax( {
type: "POST",
url: "/getView",
data: "ID=ID",
success: function(result){
$('.modal-content').html(result);
$('#myModal').modal().show();
}
} );
}
Route::get('/getView',[
'middleware'=>'auth',
'uses'=>'Controller@getView'
]);
function getView()
{
return view('myView');
}
Upvotes: 1