Katello ajax challenges - issue #6565

Hi all,

I'm working on katello issue #6565 - Only hide the media drop down if a valid kickstart url can be calculated without one

The idea is this:

  1. After the following are selected
  • Lifecycle environment
  • Content view
  • Content source
  • Architecture
  • Operating system
  1. Calculate kickstart url based on 5 select boxes above.

  2. If kickstart url can be calculated, show it instead of Foreman's Media select box. Otherwise, keep Foreman's Media select box

The challenge is this:

  • operating system select box currently has :onchange => 'os_selected(this);' with called function reload_host_params which reloads the whole form in Ajax.
  • reload_host_params discards any changes I made to hide the media select box and show the kickstart_url

Any ideas how to preserve the changes already made in the DOM by the katello plugin?

There are two other issues that I'm trying to debug that I encountered

  1. Bug #6940: Ajax 404 error on new host form if operating system is changed to blank value - Foreman - Ajax 404 error on new host form if operating system is changed to blank value

As a result, the media select box is not shown again as it should have been.

  1. function toggle_installation_medium() is being called 3 times

$(document).on('ContentLoad', function(){onKatelloHostEditLoad()});

function onKatelloHostEditLoad(){
$('#host_operatingsystem_id').live('change', function() {
toggle_installation_medium();
});
$('#host_content_source_id').live('change', function() {
toggle_installation_medium();
});
}

Thanks,

Joseph