Delete buttons in Preview zone after reset are not work

Web Tips Q & ACategory: Krajee Yii2 ExtensionsDelete buttons in Preview zone after reset are not work
Anonymous asked 2 years ago

I use your widget on form in DetailView.It works fine except a one issue:-when I want  to reset a form and restore original images in preview zone they are successfully restored, butDelete button is dead until I add aby other image.My source: resetOptions in DetailView:

$('#casestudies-images').fileinput ('refresh', { 
        '<img src="/resources/image1.png">', 
        '<img src="/resources/image2.png">'
    initialPreviewConfig: [

Corresponding column in DetailView:

'columns' => [ 
        'value'=>$this->render('_images_list', ["model"=>$model]), 
            'pluginOptions' => [
                'initialPreview'=> $aImages,
                'uploadUrl'=> "/url", 
                'maxFileCount' => 5, 
                //'allowedFileExtensions'=>["jpg", "png", "bmp", "jpeg", "gif"], 
1 Answers
spt answered 2 years ago

I have found a reason.
It is necessary to reset whole form before resetting a widget.
So, resetOptions code in the DetailsView should looks like:

$('#casestudies-images').fileinput ('refresh',  .... ); return false;"


Kartik Staff replied 2 years ago

If you are not using ajax mode of the plugin (i.e. using form based submission) – then on resetting the form – the plugin will auto reset the file input and preview.

Login or register to contribute or comment.

Login   Register