List toolbar dropdown

Hi! I’ve created a dropdown with an option to publish/unpublish a post. The value of the visible field is updated correctly. But listRefresh don’t work correctly. If I don’t refresh the browser page I can’t see the changes in the list.

image

// _list_toolbar.htm
<div class="dropdown dropdown-fixed">
<button
    type="button"
    class="btn btn-default oc-icon-eye"
    disabled="disabled"
    data-trigger=".control-list input[type=checkbox]"
    data-trigger-condition="checked"
    data-trigger-action="enable"
    onclick="$(this).data('request-data', {
        checked: $('.control-list').listWidget('getChecked')
    })"
    data-toggle="dropdown"
    >
    Change Status
</button>
<ul class="dropdown-menu" data-dropdown-title="Change Status">
    <li><a 
        tabindex="-1"
        class="oc-icon-eye"
        onclick="$(this).data('request-data', {
            checked: $('.control-list').listWidget('getChecked')
        })"
        data-request="onChangePublish"
        data-trigger-action="enable"
        data-trigger=".control-list input[type=checkbox]"
        data-trigger-condition="checked"
        data-stripe-load-indicator>Publish</a></li>
    <li><a
        tabindex="-1"
        class="oc-icon-eye-slash"
        onclick="$(this).data('request-data', {
            checked: $('.control-list').listWidget('getChecked')
        })"
        data-request="onChangeUnpublish"
        data-trigger-action="enable"
        data-trigger=".control-list input[type=checkbox]"
        data-trigger-condition="checked"
        data-stripe-load-indicator>Unpublish</a></li>
</ul>
</div>

// News.php (controller)
public function onChangePublish() {
    if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
        NewsModel::whereIn('id',$checkedIds)->update(['visible' => '1']);
    }
    return [
        'list' => $this->listRefresh()
    ];
}

Hi @Radek,

Try using #Lists that matches the id of the HTML element that contains the css class list-widget.

return [
    '#Lists' => $this->listRefresh()
];

Thank you for your answer @daft
Unfortunately when I use ‘#List’ the entire list disappears and this appears:
image

Oh! It should be

return $this->listRefresh();
1 Like

Thank you, it works! :slight_smile: