无法使用 fancybox 在 CKeditor 中输入
这是我在 cakephp 项目中用于实现 CKeditor 编辑版本的代码。
<div style='display:none'>
<div class="umsg_div" id="umsg_div">
<?php
echo $this->Form->create('Inbox',array('action'=>'private_message_reply','id' => 'form_umsg'));
?>
<ul >
<?php echo $this->Form->input('Inbox.to_id',array('type'=>'hidden','value'=>@$message_details['Inbox']['from_id'],'id'=>'to_id')); ?>
<li><div class="blue_title">Send Private Message</div></li><br/>
<li>Subject</li>
<li><?php echo $this->Form->input('Inbox.subject',array('type'=>'text','class'=>'subject','label'=>false));?></li><br/>
<li>Message</li>
<li>
<?php echo $this->Form->input('Inbox.message',array('type' => 'textarea','id'=>'user_message','rows'=>"2",'style'=>'width:130%','label'=>false));?>
<script language="javascript" type="text/javascript">
if (CKEDITOR.instances['user_message']) {
CKEDITOR.instances.user_message.destroy();
}
CKEDITOR.replace( 'user_message',{
toolbar : 'Basic',
});
</script>
</li>
<li style="text-align:right;padding:10px;"><input type="submit" name="umsg" value="Send" class="normal_button"/> or <a href="#" onclick='return hide_reply();'>Cancel</a></li>
</ul>
<?php echo $this->Form->end(); ?>
</div>
</div>
我在我的项目中的很多地方都使用了ckeditor...但是在这个地方我无法输入文本字段。
This is the code I used for implementing an edited version of CKeditor in my cakephp project.
<div style='display:none'>
<div class="umsg_div" id="umsg_div">
<?php
echo $this->Form->create('Inbox',array('action'=>'private_message_reply','id' => 'form_umsg'));
?>
<ul >
<?php echo $this->Form->input('Inbox.to_id',array('type'=>'hidden','value'=>@$message_details['Inbox']['from_id'],'id'=>'to_id')); ?>
<li><div class="blue_title">Send Private Message</div></li><br/>
<li>Subject</li>
<li><?php echo $this->Form->input('Inbox.subject',array('type'=>'text','class'=>'subject','label'=>false));?></li><br/>
<li>Message</li>
<li>
<?php echo $this->Form->input('Inbox.message',array('type' => 'textarea','id'=>'user_message','rows'=>"2",'style'=>'width:130%','label'=>false));?>
<script language="javascript" type="text/javascript">
if (CKEDITOR.instances['user_message']) {
CKEDITOR.instances.user_message.destroy();
}
CKEDITOR.replace( 'user_message',{
toolbar : 'Basic',
});
</script>
</li>
<li style="text-align:right;padding:10px;"><input type="submit" name="umsg" value="Send" class="normal_button"/> or <a href="#" onclick='return hide_reply();'>Cancel</a></li>
</ul>
<?php echo $this->Form->end(); ?>
</div>
</div>
I used ckeditor in my project in many places... but in this place I can not type in textfields.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本上 DOM 事件被覆盖,所以你需要做的是在 afterLoad 上使用 setTimeout 来解决问题:
Basically the DOM events are being overwritten so what you need to do is use a setTimeout on the afterLoad to fix the problem:
问题可能是 Fancybox 克隆了您为其提供的内容,这意味着原始 DOM 元素的所有事件处理程序都会丢失。换句话说,如果您有一个 HTML
元素,并且您已在其上注册了一个事件处理程序,例如:
并且您想要显示此
> 在 Fancybox 内,然后单击它,您将不会收到任何消息。
The problem may be that Fancybox clones what you give it as its content, which means that all of the event handlers of the original DOM elements are lost. In other words, if you have an HTML
<span>
element and you've registered an event handler on it, like:and you want to show this
<span>
inside the Fancybox, then on its click, you won't get any message.这只是前一位发帖者的扩展,前一位发帖者指出由于 Fancybox 克隆内容而无法访问 DOM 元素:
一种选择可能是在 Fancybox 完成后附加它:
这可能有点黑客行为,作为免责声明,我从未与 Fancybox 合作过。但这里是回调的 API: http://fancybox.net/api
希望这会有所帮助。
This is just an extension to the previous poster who pointed out the inaccessibility of the DOM elements due to Fancybox cloning the contents:
One option may be to attach it after the Fancybox has completed:
This might be a bit hackish and, as a disclaimer, I never worked with Fancybox. But here's the API for the callbacks: http://fancybox.net/api
Hope this helps.