Replace default message 'load failed' in C3.network.Request


#1

I need to change the value (and probably translated) of C3.network.Request.config.loadfailedText which is by default set to load failed.
This string is been used inside the childDataSourceLoadFailed function.

I tried to redefine this method to change the value been displayed with the following way:

(function() {
  var request = C3.network.Request;
  _.extend(request, {
    childDataSourceLoadFailed: function(sourceMapping, targetMappings, callback, signature) {
      var response = signature.response,
          data     = response.get('data'),
          loadfailedText = 'couscous';//this.get('loadfailedText');

      _.each(targetMappings, function(targetMapping) {
        _.each(data, function(dataItem) {
            dataItem[targetMapping.to] = loadfailedText;
        });
      });

      callback(null);
    }
  });
})();

This does not work, I still got load failed! How I can set this value?


#2

We should extend the prototype of Request.

Try:
var request = C3.network.Request.prototype;


#3

Thanks @Zicheng, this did the job for me:

var request = C3.network.Request.prototype;
request.set('loadfailedText', 'my_new_value');