lundi 28 avril 2014

Laravel 4: How to pass a div id to View::make()


Vote count:

0




This is my codes:


routes.php



Route::get('menu', function()
{
return View::make('display_food');
});


menu.blade.php



<script type="text/javascript">
function linkPage()
{
location.href = "menu";
}
</script>

......
......

<button class="btn btn-default" onclick="linkPage()">Menu</button>


I wanted to pass a div id "#link_menu" to the url so that when it loads, it is display like this "http://ift.tt/1rz6FME" which can make the page jump to the section i want. However, I have tried with



Route::get('menu', function()
{
return View::make('display_food')->with('#link_menu');
});


And



Route::get('menu', function()
{
return View::make('display_food',compact('#link_menu'));
});


And this



Route::get('menu', function()
{
return View::make('display_food')->with(compact('#link_menu'));
});


But none of them are working. The url is still display in "http://ift.tt/1nADDyu" without "#link_menu". Any ideas?



asked 8 mins ago


2 Answers



Vote count:

0




You have this url:



http://ift.tt/1rz6FME


Actually, the part after # is not submitted to the server, you need to pass using a query string like:



http://ift.tt/1kgaUK6


So you can get it using:



$menuId = Inpput::get('menuId');


answered 1 min ago



Vote count:

0




Have you read the docs? http://ift.tt/1kgaSSD and http://ift.tt/IuYVv2


To pass variables to your view, do:



View::make("display_food", array("menu" => "#link_menu"));


And then in your view:



location.href = "{{ $menu }}";


answered 1 min ago





Aucun commentaire:

Enregistrer un commentaire