0

I have my template something like this,

<ul id="items">
    {{#each items as |item index|}}
       <li>
        <!-- <input type="checkbox" id={{concat "pf" index}} /> -->
        {{input type="checkbox" id=(concat "pf" index)}}
       </li>
    {{/each}}
</ul>

And I have my js something like this,

import Ember from "ember";

export default Ember.Controller.extend({
  appName: "Ember Twiddle",
  items: [{}],
  init: function() {
    $(document).on("click.somename", function (e) {
      alert($(e.target).parent().length); //should get parent as "li" and length as 1
    });
  }
});

What happening for my project is that, if I click on ember input helper I am not able to get the parentElement using jQuery. But when I changed that input helper to normal <input type="checkbox" />, I am able to get the parentElement. I don't know whether Safari/Ember is using any virtual DOM or something to render its own helpers. This issue is happening only in Safari. In Chrome, it is working fine.

Unfortunately, I am not able to make a fiddle/plunker as the issue is not able to replicate in them. Sorry about that. In my project, I am using ember@2.7.3.

Any suggestions/help on this issue?

Abraham Gnanasingh
  • 837
  • 2
  • 10
  • 31
  • 1
    you're trying to find the `
  • `? because thats the parent of the ``. Also yeah, ember uses the `glimmer` vm to render everything, but that should work. However why the heck are you using jQuery at all and not an native ember action? Also maybe you can provide an `ember-twiddle` or even a git repo with reproduction? This also could be related to ember events, but I'm not sure because you dont use them here. but maybe [you should read this](https://medium.com/square-corner-blog/deep-dive-on-ember-events-cf684fd3b808).
  • – Lux Jun 13 '18 at 18:00
  • the given code is just a sample and is only for mentioning the problem clearer. why i used jQuery event is actually i have created some dropdown like component, so when i click outside it should hide the dropdown. that's why added that `$(document).on("click", () => {})`. in `ember-twiddle`, i tried to reproduce, but everything seems to be working fine in it – Abraham Gnanasingh Jun 13 '18 at 18:08
  • this seems weird, and I doubt its a ember problem. How is it of you use plain javascript instead of jQuery? maybe try some debugging. Can you reproduce in a new ember project and share a git(hub?) repo? – Lux Jun 13 '18 at 18:24
  • Hey I forgot to mention that the issue happening only in Safari. Sorry about that. Edited this question. And I will try to reproduce something in `ember-twiddle` or `repo` – Abraham Gnanasingh Jun 13 '18 at 18:28