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

Not applying changes #14

Closed
Hube2 opened this issue Oct 27, 2016 · 3 comments
Closed

Not applying changes #14

Hube2 opened this issue Oct 27, 2016 · 3 comments

Comments

@Hube2
Copy link

Hube2 commented Oct 27, 2016

I'm using Medium button, but it is not always working for my textarea. The only way that I can consistently get a new button to update the content is if I apply one of the standard Medium Editor buttons to the content after it. I think it might have something to do with this yabwe/medium-editor#942, but I'm not sure.

Is this still active, can anyone help me with this?

@Hube2
Copy link
Author

Hube2 commented Nov 4, 2016

Thought I'd stop back and post my solution, just in case someone else is having the same problem, although it's just a hack to make it work for what I'm using it for and not real a solution. Basically I bind a DOMSubtreeModified to every editor element and then call editor.events.updateInput() every time the editor element is modified to force the changes to take place.


    var editor = new MediumEditor($selector, $object);

    if (editor.elements.length) {
      var elements = editor.elements;

      for (i=0; i<editor.elements.length; i++) {
        // bind DOMSubtreeModified to each editor element
        var editorId = elements[i].id;

        $('#'+editorId).bind('DOMSubtreeModified', function(e) {
          // make editor element something usable by editor.events.updateInput()
          var $target = document.getElementById(e.currentTarget.id);
          // find the textarea element associated with the editor element
          // and make it usable by editor.events.updateInput()
          // not sure this matters, but specific to how i'm using it
          var $targetObj;
          $('textarea[medium-editor-textarea-id="'+e.currentTarget.id+'"]').each(function(index, element) {
            $targetObj = document.getElementById(element.id);
          });
          editor.events.updateInput($target, $targetObj);
        });
      }
    }

@arcs-
Copy link
Owner

arcs- commented Nov 11, 2016

What is the simplest way to reproduce this error?
Also, did you check the latest version? I might have fixed it.

In general, this repository is not very active.

@Hube2
Copy link
Author

Hube2 commented Nov 12, 2016

It appears that whatever you've changed has corrected the issue for me. I've commented out my work around in my code, will keep an eye on it, see what happens. Will report back if I still see a problem.

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