Joomla的模态窗口删除ID和类名 [英] Joomla's modal window removing id and class names

查看:90
本文介绍了Joomla的模态窗口删除ID和类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在模块中有一个要显示在模式窗口中的表单.根据id的不同,该窗口可能为空白,或者如果它显示任何内容,则所有类和id都将被删除,因此我无法验证或设置表单样式.

I have a form in a module that I want to appear in a modal window. Depending on the id the window may be blank, or if it does show any content all classes and ids are removed, so I can't validate or style the form.

截断的代码: ...

Truncated Code: ...

  <div id="feedback">
    <div class="feedbackinner">
      <!-- form module  -->
        <div id="contact-wrapper">
          <!--form elements with ids and classes-->
        </div>
      <!-- end module -->
    </div><!-- end .feedbackinner -->
  </div><!-- end #feedback -->

这将触发不带任何ID或类的模式窗口(使用Firefox Web Developer概述当前元素)

This triggers the modal window without any ids or classes (using Firefox Web Developer outline current elements):

<a href="#contact-wrapper" class="modal" rel="{handler: 'clone', clone: 'contact-wrapper'}">Click for ugly unstyled form that won't validate</a>

这会触发一个空白的模式窗口:

This triggers a blank modal window:

<a href="#feedback" class="modal" rel="{handler: 'clone', clone: 'feedback'}">Click if you like staring at a blank white box</a>

最重要的是,如何将所有ID和类保留在模式窗口中,为什么不调用父div工作?

So most importantly how do I keep all the ids and classes inside the modal window, and why won't calling the parent div work?

(作为一种变通方法,我将表单移至组件视图,然后使用handler: 'iframe'而不是clone对其进行了调用.我仍然想知道模态窗口是怎么回事.)

( As a work around I moved the form to a component view then called it using handler: 'iframe' instead of clone. I still want to know what's going on with the modal window. )

谢谢!

推荐答案

没有看到代码,但是在元素上使用Element.clone的含义很明显.由于HTML的性质,id表示唯一.这意味着您实际上不应该同时向DOM中注入多个具有相同id的元素.

not seen the code but implications of using Element.clone on an element are apparent. By nature of HTML, id is meant to be unique. This means you are not really supposed to have more than one element with the same id injected into the DOM at the same time.

MooTools通过从其创建以下内容的任何元素中隐式删除id来正确反映情感:

MooTools mirrors the sentiment correctly by implicitly removing the id from any element it creates a clone of:

https://github.com/mootools/mootools-core/blob/master/Source/Element/Element.js#L860

.clone方法接受可选参数,这些参数使您可以覆盖内容:

the .clone method accepts optional arguments which allow you to override stuff:

clone: function(contents, keepid){-请参见 http://mootools.net/docs/core /Element/Element#Element:clone .

克隆的元素还会丢失您可能分配给它们的所有事件(但是cloneEvents可以帮助您解决此问题).

cloned elements also lose all the events you may have assigned to them (but cloneEvents can help with that).

我建议查看squeezebox的实现,并仔细检查克隆是否以预期的方式实现.更好的做法可能是采用并重新附加元素-或复制整个innerHTML(尽管这将再次导致未委派的事件失败).

I would recommend looking at the squeezebox implementation and double check that the clone is implemented in the intended way. A better practice may be to adopt and re-attach the elements instead - or to copy the whole innerHTML (though this will once again cause non-delegated events to fail).

这篇关于Joomla的模态窗口删除ID和类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆