olton / Metro-UI-CSS

Impressive component library for expressive web development! Build responsive projects on the web with the first front-end component library in Metro Style. And now there are even more opportunities every day!
http://metroui.org.ua/
MIT License
7.02k stars 1.97k forks source link

CalendarPicker setMaxdate in runtime not working #1374

Closed dinami-k closed 5 years ago

dinami-k commented 5 years ago

In runtime i call setMaxDate method but not working....

debug metro.js and setMaxDate method change "o.maxDate" but when call "_drawContent" use "max" property for evaluate condition and not "maxDate"

I changed a local version de Metro.js and edit setMaxDate (add: this.max = new Date(o.maxDate);) like this:

i don`t if it's best approach

setMaxDate: function(date){
        var that = this, element = this.element, o = this.options;

        o.maxDate = date !== null ? date : element.attr("data-max-date");

        this.max = new Date(o.maxDate);

        this._drawContent();
    }
olton commented 5 years ago

Calendarpicker not contains method setMaxDate. To change max date You must change attribute data-max-date

dinami-k commented 5 years ago

i set $('#mycalendar').attr('data-max-date', '2019/29/06'); before Metro.init(); and work..... but in runtime after user set some conditions in my page and try $('#mycalendar').attr('data-max-date', '2019/12/12') not work :(

dinami-k commented 5 years ago

I did a sandbox (https://sandbox.org.ua/dinami-k/code/VwGD7F2vbq) but after save show 404 not found.

sandbox is: Metro4 + VueJS

HTML

<div id="app">
<input id="mycalendar" type="text" data-role="calendarpicker">
</div>

Javascript

var app = new Vue({
    el: '#app',
    data: {
        message: 'Hello Metro 4 + Vue!'
    },
    mounted: function () {
      $('#mycalendar').attr('data-max-date', '2019/05/30') //work
        Metro.init();
      $('#mycalendar').attr('data-max-date', '2019/05/31') // not work  :(
    }
});

result: calendar max date 2019/05/30 work ( before Metro.init() )... after .init() not work

olton commented 5 years ago

@dinami-k You are right. I found a bug in a calendar component. If ix it in 4.2.44

dinami-k commented 5 years ago

thanks a lot