留言板

how to access the element the datepicker is assigned to in the callback sel

thumbnail
Ivano Carrara,修改在8 年前。

how to access the element the datepicker is assigned to in the callback sel

Expert 帖子: 345 加入日期: 05-7-3 最近的帖子
There is a tutorial http://alloyui.com/versions/2.0.x/examples/datepicker/ where this code is given:

YUI().use(
  'aui-datepicker',
  function(Y) {
    new Y.DatePicker(
      {
        trigger: 'button',
        popover: {
          zIndex: 1
        },
        on: {
          selectionChange: function(event) {
            console.log(event.newSelection)
          }
        }
      }
    );
  }
);


My question is how to access the element the datepicker is assigned to, i. e. the button, in the callback selectionChange?

I tried to read the complete documentation but I didn't understand it.

Thank you in advance for any help !

Ivano C.
thumbnail
Kyle Joseph Stiemann,修改在8 年前。

RE: how to access the element the datepicker is assigned to in the callback

Liferay Master 帖子: 760 加入日期: 13-1-14 最近的帖子
Hi Ivano,
To obtain the trigger element during the selectionChange event, you can do the following:

selectionChange: function(event) {
var triggerNode = Y.one(event.target.get('trigger'));
// Your code here ...
}


See my answer to the same question on Stack Overflow for more details and a runnable example.

- Kyle
thumbnail
Ivano Carrara,修改在8 年前。

RE: how to access the element the datepicker is assigned to in the callback

Expert 帖子: 345 加入日期: 05-7-3 最近的帖子
Thank you Kyle !

And excuse me for the double post ...

Ivano C.
thumbnail
Kyle Joseph Stiemann,修改在8 年前。

RE: how to access the element the datepicker is assigned to in the callback

Liferay Master 帖子: 760 加入日期: 13-1-14 最近的帖子
Glad I could help! Please mark my post as an answer here and on Stack Overflow if it answers the question.

- Kyle