1

I have selecting, unselect and unselecting event. But when I click on select all or unselect all none of these events are called.

This is the plugin link http://demos.krajee.com/widget-details/select2

2
  • Selec2 Event List Commented Feb 16, 2017 at 10:59
  • None of event are calling when I click Select All/Unselect all
    – Ish
    Commented Feb 16, 2017 at 11:22

3 Answers 3

3

There is an event that is fired. Its logic is defined in here:

Select2 Krajee JS Official Source Code

The name of the event for select all is krajeeselect2:selectall and for unselect all is krajeeselect2:unselectall.

Consuming the event via JQuery is done as always:

$('#myKartikSelect2Id').on("krajeeselect2:selectall", function (e) {
    console.log(e);
});

$('#myKartikSelect2Id').on("krajeeselect2:unselectall", function (e) {
    console.log(e);
});

Hope it helps (:

5
  • Thanks. It was helpful. I was using select2:selectall
    – Ish
    Commented May 30, 2017 at 19:09
  • This answer can be partially correct but not entirely. After this krajeeselect2:selectall event the change event is triggering and so this event is not acting the same way like select2:select or select2:unselect event
    – Ish
    Commented Jun 1, 2017 at 2:28
  • @Ish maybe if you could elaborate a little more of why this behaviour is undesired? As I understood you needed an event that fired on Select All and UnSelect All, and krajeeselect2:(un)selectall does specifically that. The source code has no other event that fires on (un)select all scenarios. Commented Jun 1, 2017 at 16:26
  • I have a similar problem, what can i do
    – ovicko
    Commented Aug 7, 2019 at 17:51
  • @ovicko is your problem the one explained in the question? If so, the answer provided solves it. If not, could you elaborate? Commented Aug 7, 2019 at 23:19
0

I don't find better solution but with this options you can override "Select all" checkbox with empty space.

'toggleAllSettings' => [
   'selectLabel' => '',
   'unselectLabel' => '',
   'selectOptions' => ['class' => 'text-success'],
   'unselectOptions' => ['class' => 'text-danger'],
],
0

Maybe not very correct, but using this works $this->renderAjax()

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 30, 2022 at 3:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.