mardi 9 juillet 2019

Using jquery load in laravel

I have an already existent project in laravel which worked with frames.. A url like: example.com/ID/paramA/paramB/paramC brings me some html

I have made a page at example.com/index with a div inside

<div class='loaded_content'>
</div>

I have a menu with my links and I use jquery load as this:

$('a#link').click(function(event) {
url=$(this).attr('href');
$('.loaded_content').load(url);
}

Is that a good practice? I wanted to get rid off frames without changing many things.

And the second part that is actually a problem.. At first I had only one menu item that created Urls like example.com/ID/paramA/paramB/paramC but paramA is fixed(always X). So menu items have href like example.com/ID/X/paramB/paramC

I now want a second menu that changes paramA with the one that is clicked.. This menu appears only after a click is made in the first menu. Is it good practice to do a replace;

value=$(this).attr('data-value');
url=url.replace("/X/", value).replace("/Y/", value).replace("/Z/", value);

The reason I am doing this is because laravel generates a route with a default paramA (always X). Is there any way to create a url in laravel with just:

/paramB/paramC/

I am using



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire