当前位置: 动力学知识库 > 问答 > 编程问答 >

php - dynamically load views partials laravel

问题描述:

Hello I have an issue when it comes to display my creating product form.

The main problem is that i have some fields different from one category to other and i want to display it just with what is needed for a specific category so what i thought is how i can load a partial based on select list.

The workflow is:

  1. I am selecting the product type

  2. I am selecting category

  3. The form partial is displayed.

Yes i could have done this with jquery hiding and toggling classes with fadeIn and fadeOut but is there a way how this could be performed from the laravel part ?

网友答案:

Well you could use ajax calls to load the proper partials for a specific category.

public function controllerMethod()
{
  if (Request::ajax())
  {
     $partial = Request::input('selected_category_partial_name');

     // The foldr stucture would have to be /views/partials/category/name.blade.php
     return view("partials.category.$partial");
  }      
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: