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

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

raydlevel5raydlevel5 Posts: 98Questions: 43Answers: 1
edited July 16 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: 50,842Questions: 1Answers: 7,620 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: 50,842Questions: 1Answers: 7,620 Site admin
    Answer ✓

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

    Allan

Sign In or Register to comment.