Comment 3 for bug 482235

Revision history for this message
Māris Fogels (mars) wrote :

Instead of a 'get_initial_value' attribute, I suggest calling the attribute simply 'initial_value'. The user sets it in the constructor.

To support your case, I suggest it support the user setting the value as a function. If initial_value is a function, then getting it will return that function's value.

// Support setting the initial value as a static text string
new Y.Picker({
  initial_value: 'foobar',
  input: 'input#baz'
});

// Support computing the initial value using a function
new Y.Picker({
  initial_value: function(input) {
    // Grabs the initial value from the DOM. The input node is passed in as a parameter to make things easier for the user.
    return input.get('value');
  },
  input: 'input#baz'
});