Can you use THIS to reference an Editor's instance name?

Can you use THIS to reference an Editor's instance name?

rldean1rldean1 Posts: 141Questions: 66Answers: 1
edited July 2019 in Editor

A lot of the times, when I'm inside of an Editor instance, I need to get or set content within that instance.

Is there a way to get the name of the instance you are in? AND/OR, is there a way to reference the name of the instance when performing other tasks?

Like, in this pusedo-code:

dteSchedules = new $.fn.dataTable.Editor({

  //stuff to configure editor

}).dependent('FieldA', function(val) {

  dteSchedules.field('FieldB').val('set a value');

  // can "THIS" be used to reference this instance of dteSchedules?
  // "this", as in, this Editor instance's name

  this.field('FieldB').val('set a value')

});

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Good point - currently no you can't, but that is something I think it should do and I'll have that in for 1.9.1. If you want to make the change locally, search for this line:

    var o = url( field.val(), data, update );
    

    and replace with:

    var o = url.call( that, field.val(), data, update );
    

    That will let you use this inside the dependent() callback to access the Editor instance in question.

    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    To confirm - this has now been committed in for 1.9.1 :).

    Allan

This discussion has been closed.