maddhatter / laravel-fullcalendar

Laravel FullCalendar.io Helper
627 stars 267 forks source link

Custom button click option not working - Laravel 5.6 #104

Open faridhub95 opened 6 years ago

faridhub95 commented 6 years ago

Hi,

I've added a custom button option on my laravel controller. It successfully displays the custom button but when I click it, it doesn't work & I got an error on my browser console log.

Error on console log:

fullcalendar.min.js:11 Uncaught TypeError: l.click.call is not a function
at g (fullcalendar.min.js:11)

My code:

$calendar = \Calendar::addEvents($eventsCollections) //add an array with addEvents
            ->setOptions([ //set fullcalendar options
                'firstDay' => 1,
                'themeSystem' => 'bootstrap4',
                'bootstrapFontAwesome' => false,
                'customButtons' => [
                    'myCustomButton' => [
                      'text' => 'custom!',
                      'click' => 'function() { alert("clicked the custom button!");}'
                    ]
                ],
                'header' => [
                    'left' => 'prev,next today myCustomButton',
                    'center' => 'title',
                    'right' => 'month,agendaWeek,agendaDay'
                  ]
            ])->setCallbacks([ //set fullcalendar callback options (will not be JSON encoded)
                //'viewRender' => 'function() {alert("Callbacks!");}'
            ]);

What could be the reason for it? or am I doing it wrong?

I'm still learning so any help would be appreciated :)

thanks

Juuuke commented 6 years ago

Hey, did you solve the problem ?

faridhub95 commented 6 years ago

Hi @Juuuke ,

Nope haven't found the solution for it.

ghost commented 6 years ago

Hi @Juuuke, look at the classes of the buttons and add own jquery-Calls for it. e.g.: $('.fc-myCustomButton-button').click( function() { alert('clicked'); });

ghost commented 6 years ago

Its based on this problem https://github.com/maddhatter/laravel-fullcalendar/pull/35