D
D
Dangetsu-PK2017-10-29 16:59:04
RequireJS
Dangetsu-PK, 2017-10-29 16:59:04

Is it possible to change an already declared function in requirejs?

There was a task to write an extension that will complement some of the functionality of the site. And the function I need is written like this:

define("lib/interface/leads/pipeline/unsorted/item", ["require", "jquery", "underscore", "twig", "cocktail", "lib/core/view", "lib/components/mail/api", "lib/components/base/confirm", "lib/components/base/player", "lib/interface/leads/pipeline/unsorted/mixins/unsorted_linking_up", "lib/utils/account/users"], function(e) {
    "use strict";
// объявления переменных
return o.extend({
// еще куча кода
acceptClick: function(e) {
            e.stopPropagation(),
            e.preventDefault(),
            this.$el.trigger("unsorted:accept:click"),
            this.model.accept({
                status_id: this.options.statuses[0]
            })
        }
  })
})

I have never worked with this framework, and I don’t know if it’s possible to somehow rewrite or supplement the function I need from outside. If possible, I would like to know how.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cat Anton, 2017-10-30
@27cm

Use requirejs.undef() and then re-declare the module:

requirejs.undef("lib/interface/leads/pipeline/unsorted/item");
define("lib/interface/leads/pipeline/unsorted/item", [...], function(e) {
    // Новое объявление модуля
});

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question