Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nao consigo adicionar os eventos recebidos em Php #91

Open
ThiagoSilvac opened this issue May 10, 2024 · 1 comment
Open

nao consigo adicionar os eventos recebidos em Php #91

ThiagoSilvac opened this issue May 10, 2024 · 1 comment

Comments

@ThiagoSilvac
Copy link

Carrego os eventos corretamente do banco de dados atraves do php e transformando em json porem os eventos nao conseguem ser exibidos nos dias do calendario , alguem tem essa soluçao ?

@Svobodennn
Copy link

        $('#calendar').evoCalendar({
            theme: 'Midnight Blue',
            language: 'tr',
            firstDayOfWeek: 1,
        });

        const events = {$data} || [];

        if (events.length > 0) {
            const calendarEvents = events.map(event => {
                // Initialize event object with common properties
                const eventObj = {
                    id: event.id, // Event ID
                    name: event.name, // Event name (e.g., "Bugün benim doğum günüm")
                    description: event.description, // Event description (e.g., "Hem sarhoşum hem yastayım")
                    type: event.type, // Event type (e.g., "birthday")
                    color: event.color, // Event color (e.g., "#8d02b3")
                    badge: event.badge, // Badge (e.g., "Teoman")
                    everyYear: event.every_year === 1, // every_year flag (convert 1/0 to true/false)
                };

                // Conditionally set the date depending on whether the event has multiple dates
                if (event.multiple) {
                    eventObj.date = [event.start_date, event.end_date]; // Multiple dates
                } else {
                    eventObj.date = event.date; // Single date
                }

                return eventObj; // Return the formatted event object
            });

            $('#calendar').evoCalendar('addCalendarEvent', calendarEvents);
        }
    })
    
    ### try put your data in here =>         const events = {$data} || [];

    
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants