Nerian / bootstrap-wysihtml5-rails

WYSIWYG editor for Bootstrap, integrated in Rails assets pipeline
437 stars 260 forks source link

Capturing keyup/keydown/etc,... events not working in Firefox #103

Closed subvertallchris closed 9 years ago

subvertallchris commented 10 years ago

I'm using this gem happy with a textarea and hooking into keypress event to save the user's text on occasion as they type. This works perfectly in every browser except for Firefox sometime around v32. We know it worked in v30, can't say for 31, but 32+ is not working. All other browsers seem fine. Here's the relevant portion of the code.

if ($('#note-form, .edit_note').length) {
  $('#note_text').wysihtml5;
  startProcess();
}

startProcess = function() {
  var sandbox;
  sandbox = $('.wysihtml5-sandbox').contents().find('body');
  return sandbox.on('keypress', function() {
    return console.log('here');
  });
};

Any ideas?

subvertallchris commented 10 years ago

I was able to work around this by hooking into the newword:composer event.

$('#note_text').wysihtml5({
  'events': {
    'newword:composer': function() {
      return startProcess();
    }
  }
});

startProcess = function() {
  return console.log('here');
};

This gets the job done, arguably more efficiently, but I'd love an idea of why the original wouldn't work if you have one.

Nerian commented 9 years ago

Sorry, not sure. But it's great you figured it out :)