使用.load加载内容后,JqueryRotate停止工作

时间:2022-01-07 13:20:03

I'm using AJAX for load content into a div, I haven't found another way to achieve what I need. I have a playlist on top and everytime the user cliked on a new page the song started again so I had to use AJAX for load the content without reloading the page.

我正在使用AJAX将内容加载到div中,我还没有找到另一种方法来实现我需要的东西。我在顶部有一个播放列表,每当用户在新页面上重新开始播放该歌曲时,我就不得不使用AJAX加载内容而无需重新加载页面。

Then I got the first problem: the content I load works perfect if I include Jquery and the plugin needed for that content in the loaded file itself, in this case, a slider but when the content is loaded JqueryRotate stops working.

然后我遇到了第一个问题:如果我在加载的文件本身中包含Jquery和该内容所需的插件,我加载的内容是完美的,在这种情况下,滑块但是当内容加载时,JqueryRotate停止工作。

I am using JqueryRotate for the buttons that load the content, when you hover them, it rotates a circle but when you click one of those buttons, the content is loaded and the the rotation doesn't work anymore. Buttons are outside the placed content.

我使用JqueryRotate作为加载内容的按钮,当你将它们悬停时,它会旋转一个圆圈但是当你单击其中一个按钮时,内容会被加载并且旋转不再起作用。按钮位于放置的内容之外。

The client wants that rotation effect so I can't just skip that plugin (I would love to, since everything else works perfect).

客户想要旋转效果,所以我不能跳过那个插件(我很乐意,因为其他一切都很完美)。

I was using all the plugins togheter and they worked perfectly, then client requested me to keep the playlist playing while you navigate to the other pages, so I had to .load the content and then I got that first issue.

我正在使用所有插件来完成它们并且它们完美地运行,然后客户端要求我在导航到其他页面时保持播放列表播放,所以我必须。载入内容然后我得到了第一个问题。

The code I'm using for the buttons to rotate:

我用来旋转按钮的代码:

$("#boton").hover( 
   function () {
            $(".img").rotate({animateTo:180})
        },
         function () {
            $(".img").rotate({animateTo:0})
        }
);

This other for a dropdown menu:

另一个用于下拉菜单:

    $('#boton').click(function () {
$('#dsubmenu').toggle(),
$('.tsubmenu, .tmsubmenu').hide();});

What options do I have? Should I search for another plugin? I've been browsing and this one is the smallest and the most efficient. I don't wanna change the whole site for just a button, so CSS3 could be another option? Thanks in advance for your answer!

我有什么选择?我应该搜索另一个插件吗?我一直在浏览,这是最小和最有效的。我不想只为一个按钮更改整个网站,所以CSS3可能是另一种选择?在此先感谢您的回答!

[EDIT Solved!!: I leave the solution here in case someone has a similar problem]

[编辑解决!!:我留下解决方案以防万一有类似的问题]

I did what Guffa said in this post (http://*.com/questions/6186483/apply-jquery-functions-to-loaded-elements):

我做了Guffa在这篇文章中所说的内容(http://*.com/questions/6186483/apply-jquery-functions-to-loaded-elements):

You can put a callback in the load call, which will be called when the new content has been added: $("#load_cheque").load("./server/mode_paiement.php?cheque=1", function(){ // Here you can fix the loaded content });

您可以在加载调用中放置一个回调函数,该函数将在添加新内容时调用:$(“#load_cheque”)。load(“./ server / mode_paiement.php?check = 1”,function(){ //在这里你可以修复加载的内容});

I included all the .js of the plugins in the main xhtml with header.js, then I loaded the content via AJAX and in the callback added the function for the slider to work, same with the other pages. Thanks Guffa! You saved me!

我使用header.js在主xhtml中包含了插件的所有.js,然后我通过AJAX加载了内容,并在回调中添加了滑块工作的功能,与其他页面相同。谢谢Guffa!你救了我!

1 个解决方案

#1


0  

try using .getScript ( http://api.jquery.com/jQuery.getScript/ )

尝试使用.getScript(http://api.jquery.com/jQuery.getScript/)

#1


0  

try using .getScript ( http://api.jquery.com/jQuery.getScript/ )

尝试使用.getScript(http://api.jquery.com/jQuery.getScript/)