Hello,

So I need to loop over a bunch of cockpit.spawns, but after each one is done I need to print a success message

    for (var attr in mods){
      var cmd = [DSCONF, '-j', 'ldapi://%2fvar%2frun%2f' + server_id + '.socket','config', 'replace'];
      cmd.push(attr + "=" + mods[attr]);

      cockpit.spawn(cmd, { superuser: true, "err": "message"}).done(function() {
        // Success update config_value dict
        config_values[attr] = mods[attr];
        console.log("Success for: " + attr);   // But attr is now different!!!!!!
      }).fail(function(data) {
        // Log error and reset the html
        popup_err("Error", "Failed to update attribute: " + attr + "\n\n" +  data);
        $("#" + attr).val(config_values[attr]);
      });
    }


The problem is that when the first promise finishes "attr" has already changed.  Is there a way to pass/store a copy of "attr" to the spawn() command so that it can be accessed in done() & fail()?  I'm not seeing anything in the docs to do this, but figured I'd ask.


Thanks,

Mark


_______________________________________________
cockpit-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/[email protected]/message/HYIFRMF7SXEQKZWMVOQ7NZXIV7FI5F44/

Reply via email to