0

I have some Ext.js code and I want to create a function that gets a date and returns it. When I implament this code below, the dropdown list box where the dates are supposed to go shows the actual function code itself. Can anyone help?

                        fields: ['yearData', 'yearDisplay'],
                        //data: [['2012', '2012'], ['2013', '2013'], ['2014', '2014']]
                        data: [['2012', '2012'], ['2013', '2013'], [function () {
                            var d = new Date();
                            var n = d.getFullYear();
                            return n + 1;
                        }, function () {
                            var d = new Date();
                            var n = d.getFullYear();
                            return n + 1;
                        }]]
                    }),
                    displayField: 'yearDisplay',

In the dropdown list on the screen it shows (below) and not '2014'

                            function () {
                            var d = new Date();
                            var n = d.getFullYear();
                            return n + 1;

1 Answer 1

1

This is untested, but you might try replacing the function

function () {
    var d = new Date();
    var n = d.getFullYear();
    return n + 1;
}

with the result of calling it:

(function () {
    var d = new Date();
    var n = d.getFullYear();
    return n + 1;
})()

In this particular case, it may be clearer and more succinct to simply do

new Date().getFullYear()+1
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.