I toggle editable by clicking on a different (a pencil icon) DOM object. This works fine for simple text
values, now I need an select
box and preferbly the select2
dropdown.
On all other fields and the regular select dropdown I use the following:
$('.edit-last_name').click(function(e){
e.stopPropagation();
$('#last_name').editable('toggle');
});
For the select 2 dropdown I need to pass aditional params to editable, but I have no idea how to do it, the code below does not work. (the element is not triggerd)
$('.edit-country').click(function(e){
e.stopPropagation();
$('#country').editable({
toggle: 'show',
select2: {
width: 200,
placeholder: 'Select country',
allowClear: true
}
})
});
Here is the html:
<div class="row edit-line">
<div class="col-md-3 col-xs-4">
<strong>@lang('user.country')</strong>
</div>
<div class="col-md-6 col-xs-8 text-right">
<span id="country" class="edit-field" data-type="select" data-source="{{ route('countries') }}" data-value="{{ $user->country }}" data-pk="{{ $user->id }}" data-url="{{ action('UsersController@update') }}" data-title="@lang('user.country')">{{ Countries::getOne($user->country, App::getLocale(), 'cldr'); }}</span>
</div>
<div class="col-md-3 text-muted hidden-xs">
<a href="#" class="edit-country text-muted text-no-underline small"><i class="fa fa-pencil"></i> @lang('general.edit')</a>
</div>
</div>
In fact it has notting to do specifically with select2, I just don't know how to pass params to editable.