New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.parent.one is not a function #2154

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

Comments

Projects
None yet
3 participants
@markgarrigan

markgarrigan commented Dec 12, 2016

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

This comment has been minimized.

Show comment
Hide comment
@markgarrigan

markgarrigan Dec 13, 2016

#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.

markgarrigan commented Dec 13, 2016

#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

This comment has been minimized.

Show comment
Hide comment
@rsbondi

rsbondi Dec 13, 2016

Member
          <tr each={ item in bad_items }>
            <td>
              { item.description }
Member

rsbondi commented Dec 13, 2016

          <tr each={ item in bad_items }>
            <td>
              { item.description }
@markgarrigan

This comment has been minimized.

Show comment
Hide comment
@markgarrigan

markgarrigan Dec 16, 2016

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!

markgarrigan commented Dec 16, 2016

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment