1

jquery.unobtrusive-ajax.js looks like the following:

enter image description here

I would like to add the following event to the library so that I can use asyncRequest() function but in a different file.

$(document).on("change", "select[data-ajax=true]", function (evt) {
    evt.preventDefault();
    asyncRequest(this, {
        url: this.href,
        type: "GET",
        data: []
    });
});
Amit Hasan
  • 1,230
  • 1
  • 14
  • 30

1 Answers1

1

Its not possible, only workaround would be to emulate a click or submit event on a hidden form control whenever your form changes.

The function declarations inside the IIFE (Immediatly invoked function expression) are a basic closure pattern, no way to access them other than calling the functions inside the closure which expose them, which, in this example, would only be possible by firing up the corresponding events.

Kevin Dreßler
  • 405
  • 2
  • 14