Suppose I have a function to build the option fields of a select
def get_options():
return [('1', 'option1'),
('2', 'option2', {'selected':True}),
('3', 'option3)]
It works well with a select field (SingleSelectField) in a Kid template
and 'option2' is selected on my form when it's displayed.
Now, I want to get these values through a MochiKit/JSON call. So I add
an exposed function to call get_options, and write a few JS code to
make the call and get the values back.
displayResults is the callback of the JSON call
UpdateSelectField.prototype.displayResults = function(result) {
replaceChildNodes(this.selectField, map(this.row_display,
result[this.resultName]));
}
UpdateSelectField.prototype.row_display = function(option) {
if (option.length > 2) {
return OPTION({'value':option[0], 'selected':'selected'},
option[1]);
}
return OPTION({'value':option[0]}, option[1])
}
My question is about row_display : It works, but I'm not pleased with
what I wrote to deal with the 'selected' attribute.
Is there a more elegant method to get the attributes passed in
option[2], in order to get all the different attributes and not assume
that the only attribute will be 'selected'...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---