Act on datepicker dom events

0
I am working on a widget for which I need to act on the Change/Input html dom event of the datepicker it's input field. For any other inputs like input, radio, checkbox, et cetera it works fine, but none of the datepickers seems to trigger this. i tried the default datepicker (dijit) and also the appstore versions (bootstrap, jquery) but with the same results. i noticed that one of the appstore modules is using the Mendix client API 'mx.data.set' to update the value of the input. So I also tried to subscribe using 'mx.data.subscribe' but subscriptions are not informed when the 'set' method is called? Only when I explicitly trigger the mx.data.update function it appears that my subscribers are being informed. Can it still be done with html dom events? Is trying to subscribe to changes with 'mx.data' the way forward? Any other suggestions? 
asked
2 answers
2

I think subscribing to changes on attributes is the way to go.

Be sure to subscribe to changes on the attribute specifically.
I use the snippet below in a custom date-time picker and it works perfectly.

this.subscribe({
                    guid: this._contextObj,
                    attr: this.dateAttribute,
                    callback: lang.hitch(this, this._setDatePicker)
                });

It also listens to changes that I trigger using set() on the object in the client (without committing to the runtime).

this._contextObj.set(this.dateAttribute, event.date.valueOf());

Hope it helps!

answered
1

Hi Alexander,

 

Not sure if this helps but as far as I know the mx.data.set only sets the value locally, meaning in the clients memory. This will cause the value to be updated if it is used in other client widgets. To send the data to the server use the mx.data.commit (the name is a bit misleading since this does not cause an actual db commit, it just sends the data to mx runtime on the server). At least this is what I think is hapening while struggling with a similar issue (I have only tried this in mx version 6.5.1)

 

Hope this helps,

-Andrej

answered