this.parent.one is not a function #2154

Closed
markgarrigan opened this Issue Dec 12, 2016 · 3 comments

Projects

None yet

3 participants

@markgarrigan

Help us to manage our issues by answering the following:

  1. Describe your issue:
    I'm looping through an array of objects. I do this all the time. However, currently I'm running into an issue where I receive an error in the console that says "this.parent.one is not a function". It seems to be caused when the object in the array has a key of "parent".

  2. Can you reproduce the issue?
    Yes

http://jsfiddle.net/markgarrigan/a4hza871/

  1. On which browser/OS does the issue appear?
    Chrome/OS X

  2. Which version of Riot does it affect?
    3.0.2

  3. How would you tag this issue?

  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@GianlucaGuarini GianlucaGuarini added the bug label Dec 13, 2016
@markgarrigan
markgarrigan commented Dec 13, 2016 edited

#1713

I see there was already discussion about this. I understand renaming my key is a work around, however, when working with 3rd party api and JSON this doesn't seem like the best solution. For now, the renaming of the key is not a big deal. But, hopefully, there's a way to fix it in the core.

@rsbondi
Contributor
rsbondi commented Dec 13, 2016
          <tr each={ item in bad_items }>
            <td>
              { item.description }
@markgarrigan

Thanks @rsbondi! I see that does help. However, is that the fix or just another workaround? Seems like documentation may be needed?? Since it may be confusing for some people accessing the item in an event handler.

http://jsfiddle.net/markgarrigan/mbvmdww6/

<p each={ item in bad_items } onclick={ parent.remove }>{ item.description }</p>

remove(ev) {
  var item = ev.item.item
}

Maybe that's ok or just common sense? I'm not sure?

Regardless, thanks again for the help!

@GianlucaGuarini GianlucaGuarini added a commit that closed this issue Dec 18, 2016
@GianlucaGuarini GianlucaGuarini closes #2154 0a414bb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment