Apply Alloy UI 1.5 datepicker to multiple instances

Posted by MyTitle on Stack Overflow See other posts from Stack Overflow or by MyTitle
Published on 2013-10-24T09:52:52Z Indexed on 2013/10/24 9:53 UTC
Read the original article Hit count: 248

Filed under:
|

I want to create Alloy UI datapickers on multiple form fields:

<div id="date_1_wrapper">
    <input type="text" class="datepick" id="date_1" />
</div>
<div id="date_2_wrapper">
    <input type="text" class="datepick" id="date_2" />
</div>

Using JQuery I can do it using following code:

$('.datepick').each(function(){
    $(this).datepicker();
});

But how to achieve same functionality in Alloy UI?

For now I use following code, but this code apply DatePickers by ID, not by CSS class in loop:

AUI().use(
        'aui-datepicker',
        function(A) {

            new A.DatePicker (
                    {
                        calendar: {
                            dateFormat: '%d/%m/%Y'
                        },
                        trigger: '#date_1'
                    }
            ).render('#date_1_wrapper');

            new A.DatePicker(
                    {
                        calendar: {
                            dateFormat: '%d/%m/%
                        },
                        trigger: '#date_2'
                    }
            ).render('#date_2_wrapper');
        }
);

I think it this code can be used in beginning, but how to deal with input's and div's ID's?

(A.all('.datepcik').each(function() {)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about alloy-ui