2016-12-08 7 views

答えて

1

簡単な例でレンダリングされなければならない

<td><?= Html::input('text' , 'name' = '[DefVendors]["name"]'); ?></td> 
<td><?= Html::input('text' , 'name' = '[DefVendors]["address"]'); ?></td> 
<td><?= Html::input('text' , 'name' = '[DefVendors]["email"]'); ?></td> 
<td><?= Html::input('text' , 'name' = '[DefVendors]["contact"]'); ?></td> 
<td><?= Html::input('text' , 'name' = '[DefVendors]["bank_name"]'); ?></td> 
<td><?= Html::input('text' , 'name' = '[DefVendors]["bank_accountno"]'); ?></td> 
<td><?= Html::dropDwonList($modelVendors , 'company_id' , arrayHelper::map(defCompanies::find()->all() , 'id' ,'name' , ['prompt' => 'Select Company'])) ?></td> 

、ここをレンダリングするページです。

コントローラ

class ExampleController extends Controller { 

    public function actionIndex() 
    { 
     return $this->ajaxResponse(true, $this->renderPartial('your_view',[])); 
    } 

    private function ajaxResponse($success = true, $content = '') 
    { 
     $response = [ 
      'success' => $success, 
      'content' => $content 

     ]; 
     echo json_encode($response); 
     return $success; 
    } 
} 

はJavaScript

$.get('example/index', (html) => { 
    var response = JSON.parse(html); 
    $('#your-selector').html(response.content); 
}); 
関連する問題