Latest

Monday, July 10, 2017

Laravel full calendar error

Asked by: Nuno


i know that there are a lot of questions about this subject in here but unfortunately i cant solve my error.

my code:

  use  namespace App;

use Illuminate\Database\Eloquent\Model;

class EventModel extends Model implements \MaddHatter\LaravelFullcalendar\Event
{
    //
    protected $dates = ['start', 'end'];
    protected $table = 'event_model';

    public function getId() {
        return $this->id;
    }

    /**
     * Get the event's title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Is it an all day event?
     *
     * @return bool
     */
    public function isAllDay()
    {
        return (bool)$this->all_day;
    }

    /**
     * Get the start time
     *
     * @return DateTime
     */
    public function getStart()
    {
        return $this->start;
    }

    /**
     * Get the end time
     *
     * @return DateTime
     */
    public function getEnd()
    {
        return $this->end;
    }
    // Implement all Event methods ...

        /**
         * Get the event's ID
         *
         * @return int|string|null
         */
}

my controller:

      $events = [];
  $events[] = $events[] = \Calendar::event(
    'Teste',
     false,
     '2017-07-10',
     '2017-07-10'
   );
  $events[] = \Calendar::event(
    'Teste2', //event title
    true, //full day event?
    new DateTime('2017-07-14'), //start time (you can also use Carbon instead of DateTime)
    new DateTime('2015-07-14') //end time (you can also use Carbon instead of DateTime)
  );

  $eloquentEvent = EventModel::first();
  $calendar = \Calendar::addEvents($events)
    ->addEvent($eloquentEvent, ['color' => '#800',
    ])->setOptions([
      'firstDay' => 1
    ])->setCallbacks(['viewRender' => 'function() {alert("Callbacks");}'
  ]);
  return view('my view', compact('calendar'))

my view:

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.min.css"/> 
//...//
{!! $calendar->calendar() !!}
{!! $calendar->script() !!}

My error:

> 3:259 Uncaught TypeError: $(...).fullCalendar is not a function
    at HTMLDocument.<anonymous> (3:259)
    at j (jquery.js:3094)
    at Object.fireWith [as resolveWith] (jquery.js:3206)
    at Function.ready (jquery.js:3412)
    at HTMLDocument.I (jquery.js:3428)

I think my error happen becouse of the script but i have the same calender in other controller with the same libs and it works fine, the different is that this controller and this view has more code but i think that it not a problem.

I need help



Source

No comments:

Post a Comment

Adbox