You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
}
}),`
The text was updated successfully, but these errors were encountered:
I had the same issue, and to easily fix it, I did this :
Create a variable outside of the extension : var parentelm;
Set the variable value with the parent if not declared :
action: function (html, mark, parent){
if (parentelm == undefined) {
parentelm = parent;
};
Now you can use the same parent multiple times by using parentelm without selecting parent's parent.
Note : you need to reset the `parentelm` value to `undefined` each time you switch to an other editable element.
Otherwise, the parent will not change and the button will act to the first editable element's parent
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:
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
The text was updated successfully, but these errors were encountered: