1

I used textarea tag instead this div[contentEditable="true] before, but it have an issue with text resizing on user typing; and this is the code, that worked in textarea version:

Template.mainFrame.events({
  'click button': function(e, t) {
    var inputted = t.find('#textarea').value;
    Session.set('input', inputted);
    t.find('#textarea').value = '';
  }
});

Template.mainFrame.someValue = function(){
    return Session.get('input');
};

html:

  <section>
        <div class="input">
          <div contentEditable="true" placeholder="type here" id="textarea">
            Lorem ipsum sit dolor
          </div>
          <button>
            click me
          </button>
        </div>
        <div class="output">
          {{#markdown}}
    {{someValue}}
          {{/markdown}}
        </div>
      </section>

But now it is not working; I guess .value method only could be applicable to textarea or inputs and this kind of stuff;

So, the question is: which method in meteor do I use to select content inside div?

Vh Ambr
  • 75
  • 1
  • 7

1 Answers1

1

This is not a meteor question, but really just about javascript (or jQuery to be precise).

The answer from here is that you can use:

var inputted = t.find('#textarea').html();
Community
  • 1
  • 1
Christian Fritz
  • 20,641
  • 3
  • 42
  • 71