0

In QooxDoo I have a problem with this code

html2plain : function (html) {
     html = html.replace(/<(S*?)[^>]*>.*?|<.*?\/>/g,  function( tag )
     {
          return this.pushHashtag(tag.toUpperCase());
      } );
      return( html );
 },

when it comes to the line

return this.pushHashtag(tag.toUpperCase());

there is no context for the variable this and the function pushHashtag becomes unavailable.

Raymond
  • 61
  • 4

1 Answers1

0

One way to solve that, is by binding 'this' to the function. To do that, you need to change the anonymous function as following (you should send this function to the replace method):

function(tag) {
  return this.pushHashtag(tag.toUpperCase());
}.bind(this)

and now, inside this function, 'this' will refer to the "right" 'this'

Jumpa
  • 878
  • 1
  • 8
  • 12