W
W
wufapexef2018-03-27 23:24:22
JavaScript
wufapexef, 2018-03-27 23:24:22

Why doesn't a function work if I assign it via an assignment?

To be honest, I'm not sure if it's because of the View, or if it's normal JS work.
Generally it works fine.

option: {
  getFilterData: {
    'terror': function (el) {
      const check = function(element) {
        return element.name === 'terror'
      }
      return el.tags.some(check)
    }
  }
}

But if I assign the same function like this, it doesn't work anymore
option: {
  getFilterData: this.function
},
function: {
  'terror': function (el) {
    const check = function(element) {
      return element.name === 'terror'
    }
    return el.tags.some(check)
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nick Sdk, 2018-03-27
@lidacriss

option: {
  getFilterData: this.function
},

1. at this place in this you will probably have an option
object 2. functions are not assigned that way. if you write getFilterData: functionNamethen in getFilterData you will receive a response from the function. What a particular function returns, not the function itself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question