我有一个联系人组列表,这些组中的每一个都可能有一个段列表或没有,如果用户选择有段的组,我需要显示段输入。有一个if语句有条件地显示段输入,但它只在我进入下一步并返回后才起作用,我如何才能实现这一点,并在用户选择具有段的组后立即显示段输入?
这是我的代码:
<div class="col-md-4 list_select_box" target-box="segments-select-box" segments-url="{{ action('SegmentController@selectBox') }}">
@include('helpers.form_control', [
'name' => 'lists_segments[' . $index . '][mail_list_uid]',
'include_blank' => trans('messages.choose'),
'type' => 'select',
'label' => trans('messages.which_list_send'),
'value' => (is_object($lists_segment_group['list']) ? $lists_segment_group['list']->uid : ""),
'options' => Auth::user()->customer->readCache('MailListSelectOptions', []),
'rules' => isset($rules) ? $rules : []
])
</div>
@if (is_object($lists_segment_group['list']) && collect($lists_segment_group['list']->readCache('SegmentSelectOptions', []))->count())
<div class="col-md-5 segments-select-box multiple">
@include('helpers.form_control', [
'value' => implode(",", $lists_segment_group['segment_uids']),
'type' => 'select',
'name' => 'lists_segments[' . $index . '][segment_uids][]',
'label' => trans('messages.which_segment_send'),
'options' => collect($lists_segment_group['list']->readCache('SegmentSelectOptions', [])),
'multiple' => true,
'quick_note' => trans('messages.leave_empty_to_choose_all_list')
])
</div>
@endif
您应该使用java-script或jQuery,希望这个jQuery插件:dkeeghan/jQuery-doWhen有帮助