Skip to content

returning htmlParentNode (or Parent) twice returns the parentnode's parent. #25

@mcbmcb0

Description

@mcbmcb0

when I repeatedly click my button I first get the actual htmlParentNode but on second and subsequent click I get a div that is the htmlParentNode's parent:

	extensions: {
		'save': new MediumButton({
			label: 'save',
			action: function (html, mark, htmlParentNode) {
				var c_id = jQuery(htmlParentNode).closest('div.editable').attr('id');
				var contents = htmlParentNode.innerHTML; // innerText
				
				alert(c_id + '\n'+ contents);
				return html
			}
		}), 

am i doing something wrong or is this a bug?
could it be as the parent is now of the menu button and not the editor div? ie this:
var sel = window.getSelection(); var parent = sel.anchorNode.parentElement;

I'm actually trying to get the id of the div that the editor instance is attached to as I have a page with many editors/ divs of editable class - is there an easy way to do that? (my goal is ajax with many editable divs).

thanks

----- edit - i'm pretty sure the parent of parent is being returned. here's a kludgy workaround

`		extensions: {
			'save': new MediumButton({
				label: 'save',
				action: function (html, mark, htmlParentNode) {
					var maybe = jQuery(htmlParentNode).find('div.editable'); //.length !== 0)
					if (maybe.length !== 0){
						htmlParentNode = maybe;
					}
					var c_id = jQuery(htmlParentNode).attr('id');
					var contents = htmlParentNode.innerHTML; // innerText
					
					alert(c_id + '\n'+ html);
					return html
				}
			}),`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions