Override delete confirm dialog in Yii2

posted in: Yii2.0 framework

Yii version In the grid view widget, the delete button uses the window confirm dialog which is simple. But it would be better if it can be changed to use the confirm dialog with bootstrap style. Since Yii2 is already integrated with the bootstrap widget. In this tutorial, I will share how I implement the new confirm dialog with a translated message by Yii::t().   Here what we will do Download the bootboxjs which is a small javascript library. It allows you … Read More

Language switcher in Yii2

posted in: Yii2.0 framework

Yii version Currently, I am building the custom application with Yii2. I want to add the language switcher in the application. I found some posts that help but these posts won’t explain well. So I try to explain what I did here. Here what we will do: create the static value in config/params.php create a language dropdown list in layout/main.php create a actionLanguage() in the controller create a LanguageSelector component create a JS file for calling the actionLanguage() via … Read More

All javascript won’t work after Pjax reloads in Yii2

posted in: Yii2.0 framework

Yii version When you work with Pjax either Pjax jquery or Pjax module, you may face the same issue as me. I am working on the Pjax widget in Yii2.0. The widget uses Pjax jquery. ProblemEvery time the Pjax reloads, all js that attached to DOM in Pjax container won’t work. CauseAfter Pjax finishes reloading, the js that set to DOM in Pjax container will not pick up on these changes. SolutionYou must reinitialize the js to DOM after … Read More

Select2 plugin does not function properly in bootstrap modal

posted in: Select2

Yii version Select2 plugin is very useful plugin when you are building the custom application or website. ProblemWhen I use the select2 inside a bootstrap modal. I can not type anything in the input field that attaches to the plugin. CauseThis issue occurs because the Bootstrap modal tends to steal focus from other elements outside of the modal. Since by default, Select2 attaches the dropdown menu to the <body> element, it is considered “outside of the modal”. SolutionAttach the dropdown to … Read More

Pjax is not working, reloads the whole page

posted in: Yii2.0 framework

Yii version Recently I am working on building the custom application with Yii2.0. I have one issue with Pjax widget. It turns out to be a common issue when you are working on Pjax. ProblemI want to render the creating form in the modal on an index page. After users submit the form, the modal will be closed and the grid view will be refreshed. This way, users won’t leave the index page. The problem is Pjax reloads the whole page … Read More

1 6 7 8 9