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

How to Bind Some dynamically create elements? #298

Open
fhgs2001 opened this issue Nov 2, 2017 · 1 comment
Open

How to Bind Some dynamically create elements? #298

fhgs2001 opened this issue Nov 2, 2017 · 1 comment

Comments

@fhgs2001
Copy link

fhgs2001 commented Nov 2, 2017

Hi
I would like to ask how can I bind element that is dynamically created using javascript?
E.g. I created a textarea using summernote plugin $(element).summernote(). The element textarea does not exist before I created it through an add button.How can I bind the textarea element?

@arggh
Copy link

arggh commented Nov 2, 2017

You should probably initialize Summernote with a callback that updates your vm property, approximately like so:

Template.editor.viewmodel({
  myText: '',

  onRendered() {
     this.editorElement.summernote({ // $('#myEditorDiv').summernote(...
       callbacks: {
          onChange: (contents) {
             this.myText(contents);
          }
       }
    });
  }
});

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