I would remove the jQuery save function that was added… and then…
Try this for the form function:
public function form( $instance ) {
// Code for editing/adding title and adding IDs to the <select> object
// ...
<?php
printf (
'<select multiple="multiple" name="%s[]" id="%s" class="widefat" size="15" style="margin-bottom:10px">',
$this->get_field_name('ID_list'),
$this->get_field_id('ID_list')
);
// Each individual option
foreach( $instance['ID_list'] as $id )
{
printf(
'<option value="%s" %s style="margin-bottom:3px;">%s</option>',
$id,
in_array( $id, $instance['ID_list']) ? 'selected="selected"' : '',
$id
);
}
echo '</select>';
}
Alright, try this update function:
<?php
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['ID_list'] = esc_sql( $new_instance['ID_list'] );
$instance['title'] = esc_sql( $new_instance['title']);
return $instance;
}