• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Launching the same inline rich text editor twice from the same page

tenants

Well-known member
#1
If you have two links to your rich text edior

(for instance, two edit links)

If you launch the editor from one link, and then the other, the editor looks skewed, for instance:

edit1)
Code:
<a href="{xen:link posts/edit, $post}" class="item control edit OverlayTrigger"
data-href="{xen:link posts/edit-inline, $post}"
data-overlayOptions="{&quot;fixed&quot;:false}"
data-messageSelector="#post-{$post.post_id}"><span>
</span>{xen:phrase edit1}</a>
and on the same page:

edit2)
Code:
<a href="{xen:link posts/edit, $post}" class="item control edit OverlayTrigger"
data-href="{xen:link posts/edit-inline, $post}"
data-overlayOptions="{&quot;fixed&quot;:false}"
data-messageSelector="#post-{$post.post_id}"><span>
</span>{xen:phrase edit2}</a>
When launching edit1 it looks fine:


1stOpen.png


On the same page, after opening Edit1, if you now open Edit2 it looks like this:

2nd.png

If you go back and try to open Edit1 again, it looks like this:

3rdopen.png


How can you put two edit links on the same page, that open the same inline rich text editor, without causing this issue
 

tenants

Well-known member
#2
hmm... I could just use a random param at the end of the url link (I'll try this). This will mean there will be two instances of the same editor hidden (and they may have different content... so that's not good)

I wish Ragtek was still around, he use to answer dev questions :cry:
 

xf_phantom

Well-known member
#3
check XenForo_ViewPublic_Post_EditInline


xf is using what you said:) => a random parameter (microtime)
PHP:
<?php
 
class XenForo_ViewPublic_Post_EditInline extends XenForo_ViewPublic_Base
{
public function renderHtml()
{
$this->_params['editorTemplate'] = XenForo_ViewPublic_Helper_Editor::getEditorTemplate(
$this, 'message',
$this->_params['post']['message'],
array('editorId' =>
'message' . $this->_params['post']['post_id'] . '_' . substr(md5(microtime(true)), -8))
);
}
}
 

tenants

Well-known member
#4
Cheers phantom, I guess that's what I'll do then

I didn't know there was a place where this could be called from 2 different buttons in the core
 

tenants

Well-known member
#5
Tested and it works with that view

There are two instances, so the 2 different editors could have different content... but it's user error if they launch it once from one button and then again from another (and expect the content to still be the same)...

It will do for me, Thanks.