模态窗口没有在joomla中显示(modal window not showing in joomla)

编程入门 行业动态 更新时间:2024-10-25 08:25:05
模态窗口没有在joomla中显示(modal window not showing in joomla)

我有动态添加a jQuery函数,当我想使用这个元素作为模态我不能,没有任何反应。

当我使用php添加相同的元素时,一切正常。

我的猜测是jQuery.modal没有看到这个元素,有没有办法解决这个问题?

我的功能看起来像这样:

$.each(respJSON, function(){ $('#poll-questions').append( $('<li>').append( $('<a>').attr('href', prefix + this.id).attr('class', 'modal') .attr('rel', '{handler: "iframe", size:{x:600, y:500}}') .append($('<span>').append(this.question) ))); });

I have jQuery function that adds a dynamicly, and when i want to use this element as modal i can't, nothing happens.

When i add the same element using php everything is working fine.

My guess is that jQuery.modal don't see this element, is there way to fix this?

My function look like this:

$.each(respJSON, function(){ $('#poll-questions').append( $('<li>').append( $('<a>').attr('href', prefix + this.id).attr('class', 'modal') .attr('rel', '{handler: "iframe", size:{x:600, y:500}}') .append($('<span>').append(this.question) ))); });

最满意答案

确保只导入1个jQuery库。 如果您有多个,请使用以下代码检查是否已导入库。 如果有,请不要包含您自己的,如果没有,请包含您自己的:

<?php // load jQuery, if not loaded before if(!JFactory::getApplication()->get('jquery')){ JFactory::getApplication()->set('jquery',true); $document = JFactory::getDocument(); $document->addScript(JURI::root() . "templates/template_name/js/jquery-1.8.3.js"); } ?>

显然改变路径,以满足您的需求。

如果这没有帮助,请确保您已正确添加了view.html.php文件的代码,如下所示:

$doc = JFactory::getDocument(); //remove this line if it's already in the file $js = '$.each(respJSON, function(){ $("#poll-questions").append( $('<li>').append( $("<a>").attr("href", prefix + this.id).attr("class", "modal") .attr("rel", "{handler: "iframe", size:{x:600, y:500}}") .append($("<span>").append(this.question) )); });' $doc->addScriptDeclaration($js);

Ensure you only have 1 jQuery library being imported. If you have more than 1, use the following code to check if there is already a library being imported. If there is, don't include your own, if there isn't, include your own:

<?php // load jQuery, if not loaded before if(!JFactory::getApplication()->get('jquery')){ JFactory::getApplication()->set('jquery',true); $document = JFactory::getDocument(); $document->addScript(JURI::root() . "templates/template_name/js/jquery-1.8.3.js"); } ?>

Obviously change the path so whatever suits your needs.

If this doesn't help, ensure you have added you code the view.html.php file correctly like so:

$doc = JFactory::getDocument(); //remove this line if it's already in the file $js = '$.each(respJSON, function(){ $("#poll-questions").append( $('<li>').append( $("<a>").attr("href", prefix + this.id).attr("class", "modal") .attr("rel", "{handler: "iframe", size:{x:600, y:500}}") .append($("<span>").append(this.question) )); });' $doc->addScriptDeclaration($js);

更多推荐

本文发布于:2023-08-07 08:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462280.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:窗口   模态   joomla   showing   window

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!