通过Ajax加载内容时未加载WORDPRESS Audio Player,未应用MediaElement.js [英] WORDPRESS Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied

查看:79
本文介绍了通过Ajax加载内容时未加载WORDPRESS Audio Player,未应用MediaElement.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个wordpress主题.当我使用Ajax加载内容时,它不会将MediaElements.js应用于音频播放器,因此不会显示音频.我认为这是因为MediaElement.js加载了wp-footer(),并且此新音频在之后添加到了DOM中,而MediaElement.js无法识别.

I'm creating a wordpress theme. When I load the content using ajax it doesn't apply MediaElements.js to my audio player, so the audio isn't display. I think this is because the MediaElement.js is loaded with wp-footer(), and this new audio is added to the DOM after, and it's not recognized for MediaElement.js.

本地视频也是如此.

我该如何解决?

推荐答案

您需要在新添加的元素上重新实例化 MediaElement 对象.

You need to reinstantiate the MediaElement object on your newly appended elements.

success: function(response){
    $('video,audio').mediaelementplayer(/* Options */);
}

或者,您可以使用 Observer 进行观看和应用.

Alternatively, you can use an Observer to watch and apply.

这篇关于通过Ajax加载内容时未加载WORDPRESS Audio Player,未应用MediaElement.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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