Giter Site home page Giter Site logo

Update issue about jqm-calendar HOT 10 CLOSED

BigG avatar BigG commented on June 24, 2024
Update issue

from jqm-calendar.

Comments (10)

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

I think you end up having two calendar instances and updating the wrong one. Please provide a JSfiddle or something so we can see the problem in the context of your application.

from jqm-calendar.

BigG avatar BigG commented on June 24, 2024

Hey, thank you for your quick answer.
In short this is the action related to the click on "Check Calendar View". All the event come out from a db.

$('#checkCalendarView').on('click', function (e) {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var arr = [];

    database.transaction(function(tx) {
             tx.executeSql('SELECT * FROM eventLog', [], function(tx, results) {
                var len = results.rows.length;
                for (var i = 0; i < len; i++) {
                var begin = createDate(results.rows.item(i).data+ " " +results.rows.item(i).hour);

                     arr.push({
                        "summary": results.rows.item(i).type,
                        "begin": begin,
                        "end": begin
                    });

                }



                 $("#calendar").jqmCalendar({
                    events : arr,
                    months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
                    days: ["Do","Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
                    startOfWeek: 1
                }, []);



        }, function(err) {
                console.log('ERROR Events: ' + JSON.stringify(err));
            });
                });

        });

In addition I checked this on your .js

$.fn.jqmCalendar = function(options) {
      return this.each(function() {
         if (!$(this).data('jqmCalendar')) {
             $(this).data('jqmCalendar', new $.jqmCalendar(this, options));
         }

      });

And if I create a new istance the old one is of course showed and the new one is correctly populated.

Where I am doing wrong?

Thanks!

from jqm-calendar.

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

Currently, a new events array can't be passed as options parameter for the update call. That should have been implemented but we never got to it. Have a look at this comment to see how to work around: #12 (comment)

from jqm-calendar.

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

You can't do this this way.

You should have something like this:

var arr = [];

$('#view').on('pageinit', function() {
             $("#calendar").jqmCalendar({
                events : arr,
                months: ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"],
                days: ["Do","Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
                startOfWeek: 1
            });
});

$('#checkCalendarView').on('click', function (e) {
database.transaction(function(tx) {
         tx.executeSql('SELECT * FROM eventLog', [], function(tx, results) {
            var len = results.rows.length;
            for (var i = 0; i < len; i++) {
            var begin = createDate(results.rows.item(i).data+ " " +results.rows.item(i).hour);

                 arr.push({
                    "summary": results.rows.item(i).type,
                    "begin": begin,
                    "end": begin
                });

            }



             $("#calendar").trigger('update');
    })
})

from jqm-calendar.

BigG avatar BigG commented on June 24, 2024

Ahhh I see the point. Nice solution!
Have you any idea how to manage doubled entry?

from jqm-calendar.

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

Clear the array first. http://stackoverflow.com/a/1232046/2104280

from jqm-calendar.

BigG avatar BigG commented on June 24, 2024

Peerfeect!!
Sometimes I forget the basics... ;)

Btw great plugin, really!

from jqm-calendar.

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

Life would have been so much easier if they just added a clear() function to the array 😉 Glad you like it and the plugin is still being used! (It's from 2013 😊 )

from jqm-calendar.

BigG avatar BigG commented on June 24, 2024

Hi there, all works as expected but there is a strange behaviour when users change day in calendar view. So basically even if events are already there (and the dot is showed just under the number) if a tap on the previous day and then I tap again on the fully populated day, no event is showed. It is seems like all is cleaned up. Do you think I need to listen to every change? I mean if my array is already populated do I need to repopulate again at every change?

Let me know..
BigG

from jqm-calendar.

jwgmeligmeyling avatar jwgmeligmeyling commented on June 24, 2024

from jqm-calendar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.