OK. I figured out that my confusion before was due to change event handlers were being triggered when I didn't expect them to and the fact that (and correct me if I'm wrong):
New selections (if they exist) are in: $("#node-input-whatever").val();
Previous selections (if they exist) are in: node.whatever
And I was also seeing some asynchronous settings of the selected items because I was populating the select list and setting the selected item in different threads.
I thought I had worked that all out and moved all manipulations (clearing, populating, setting, and triggering) into the callback function, however now the select list selections I'm setting are not getting set and the select lists always present with no selected item (no default and no previously selected item and I can't seem to figure out why.
Of the 3 lists I'm working on currently (circles, places, and people), the one that does have a selected item is the circles select list. The other 2 are populated but don't show their previously set values. And another thing that confuses me is that making selections doesn't usually cause the deploy button to activate.
So let me ask a few questions:
- When the edit dialog comes up, the only things that should be saved WRT select lists is the value of the previously saved selection. The other items in the list need to be re-populated and the previously selected one has to be explicitly selected. Is that all correct?
- What has to happen in order for the deploy button to activate? Why can I make select list selections and click done and the deploy button is still grayed out?
- When is a call to an input's change function triggered other than calling
...trigger('change')
? And why would it be called before the running of the top level code in oneditprepare?
- Does
...trigger('change')
need to be called to show the previously selected select list item?
According to my console prints in the browser's web inspector, I'm setting values in $("#node-input-whatever").val('value here')
and those values are in the list I populated before setting the selection, so I don't understand why the lists initially show no selection. Do I need to change like, the default
or something? I wouldn't think I do because my simpler node-input-event
select list and my node-input-circle
select lists show the correct selections based on my calls to .val(...)
.
One thing I suspect may be a source of one problem is that in oneditprepare and in the change function for circles, I'm not only making the server call to get the values to populate the circles select list and set its selection, but I'm also making 2 other server calls to populate the people and places given the selected circle. I.e...
oneditprepare: function() {
var node = this;
var configNodeId = $("#node-input-server").val();
$.getJSON('location/circles/' + node.id + '/' + configNodeId + '/none/none', function(data) {
...
$.getJSON('location/places/' + node.id + '/' + configNodeId + '/' + circleId + '/' + placeId, function(data) {
This does populate everything correctly. It's just the selections and the deploy button activation that doesn't seem to work...