Skip to content
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

"Error: Can not use event delegating with non-element nodes on first level" #3

Open
crazy4groovy opened this issue Aug 15, 2016 · 4 comments

Comments

@crazy4groovy
Copy link

Hi, I'm trying to reference a template within a template. Please see: https://jsfiddle.net/Lnne9wxt/

The code works fine if I remove the <submod></submod> in the main template. Can you explain if this is a bug, or otherwise how I can compose templates?

Note: I also tried using directives: https://jsfiddle.net/yktv5pve/ But I get an error: TypeError: Cannot read property 'onclick' of null

Thanks, I do like Monkberry, I think it's fantastic!

@crazy4groovy
Copy link
Author

Note: I'm importing ../monkberry-standalone/4.0.7/monkberry.min.js

@antonmedv
Copy link
Member

At first example with event delegating everything is correct. To solve this you need to wrap non-elements (like ifs, loops, custom tags) with another node (div, span):

<script type="text/monkberry" id="myTemplate1">
  <div>
     ....
  </div>
  <div>
    <submod></submod>
  </div>
</script>

Second example: error about what onclick directive does not declared. monkberry-directives package does not included to monkberry-standalone.

@crazy4groovy
Copy link
Author

Thanks. Now, my sub module references state, and it's not working again:

https://jsfiddle.net/Lnne9wxt/1/

@crazy4groovy
Copy link
Author

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants