JS AMD script is not being loaded into a profile page

Hi there. I am trying to identify the source of a problem with some JS events attached to buttons in a profile page. This is the the fragment code produced by elgg_view_form:

<input id="bt" value="Cambie su ubicación" class="elgg-button .submit" type="button">

which is associated to this script (embedded into a AMD module):

function() {
  let empName = $('#emp').val();
  $('#lblEmp').html('La nueva dir es <span style="text-transform:capitalize;">' + empName + '</span>');

  ajax.action('save_evupam', {
    data: {
      arg0: guid,
      arg1: "",
      arg2: "",
      arg3: empName,
    },
  }).done(function(output, statusText, jqXHR) {
    if (jqXHR.AjaxData.status == -1) {
      alert("La ubicación no pudo ser actualizada");
      return;
    }
    alert("Ubicación " + output.respuesta);
  });

}

It all works well in my local elgg 2.3.7 server, as you will see here: 

https://photos.google.com/photo/AF1QipNbbQRCWpt-HTEydstpLmvScEbsMV3R7jych0L3

However, when I deploy the same code in a 2.3.8 server, the Javascript never gets loaded. See:

https://photos.google.com/photo/AF1QipNVX45XMyX1JdXogDmt4ChxmVjC2uCyRXKqN6fZ

Any idea what may be wrong?

Thank you.

  • 1 AMD(jquery)
    function n()
    amd_monitor.js:1:283
    2 AMD(jquery.colorbox) undefined amd_monitor.js:1:283
    3 AMD(js/evupam) undefined amd_monitor.js:1:283
    4 AMD(languages/es)
    Object { "item:site": "Sitios", login: "Iniciar sesi&oacute;n", loginok: "Ha iniciado sesi&oacute;n", loginerror: "Inicio de sesi&oacute;n incorrecto. Verifique sus credenciales e intente nuevamente", "login:empty": "El nombre de usuario y contrase&ntilde;a son requeridos", "login:baduser": "No se pudo cargar su cuenta de usuario", "auth:nopams": "Error interno. No se encuentra un m&eacute;todo de autenticaci&oacute;n instalado", logout: "Cerrar sesi&oacute;n", logoutok: "Se ha cerrado la sesi&oacute;n", logouterror: "No se pudo cerrar la sesi&oacute;n, por favor intente nuevamente", … }
    amd_monitor.js:1:283
    5 AMD(elgg)
    Object { config: {…}, security: {…}, session: {…}, page_owner: {…}, global: Window, ACCESS_PRIVATE: 0, nullFunction: nullFunction()
    , abstractMethod: abstractMethod(), extend: extend()
    , isArray: isArray(), … }
    amd_monitor.js:1:283
    6 AMD(elgg/widgets)
    Object { init: init()
    , add: add(), move: move(), remove: remove(), collapseToggle: collapseToggle(), saveSettings: saveSettings(), setMinHeight: setMinHeight()
     }
    amd_monitor.js:1:283
    7 AMD(elgg/likes) undefined amd_monitor.js:1:283
    8 AMD(elgg/messageboard) undefined amd_monitor.js:1:283
    9 AMD(elgg/uservalidationbyemail) undefined

  • Apparently, it all reduced to this missing statement in the init:

        // registering js
        elgg_register_js('js/evupam', elgg_register_simplecache_view('js/evupam.js'), 'head');

     

     

  • That's not how you would add a JS lib on Elgg 2.x anymore. See http://learn.elgg.org/en/stable/guides/javascript.html#using-traditional-js-libraries-as-modules if you can't add the code as AMD module.