【发布时间】:2014-02-27 22:42:11
【问题描述】:
我正在制作一个 WordPress 主题
我正在试图弄清楚为什么我的所有脚本都不起作用...我在下面发布了我的完整 functions.php... 任何人都可以看到有什么问题吗?我怀疑 jquery 冲突...如果是这样,问题是什么?
如果您看不到下面的错误,请告诉我您是否需要问题所在的 url...
非常感谢!
<?php
function biscuits_enqueue() {
wp_enqueue_script( 'jquery-ui', 'https://code.jquery.com/jquery.js', array( 'jquery') );
wp_enqueue_script( 'bootstrap.min', get_template_directory_uri(). '/js/bootstrap.min.js', array( 'jquery' ) );
wp_enqueue_script( 'ekko-lightbox', get_template_directory_uri(). '/js/ekko-lightbox.js', array( 'jquery' ) );
}
add_action('wp_footer', 'biscuits_enqueue');
?>
<script>
$(document).ready(function($){
//lightbox
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
event.preventDefault();
$(this).ekkoLightbox();
});
//bs-sidebar
$(function () {
var $window = $(window)
var $body = $(document.body)
var $sideBar = $('.bs-sidebar')
var navHeight = $('.navbar').outerHeight(true) + 10
$body.scrollspy({
target: '.bs-sidebar',
offset: navHeight
})
$('.bs-docs-container [href=#]').click(function (e) {
e.preventDefault()
})
// back to top
setTimeout(function () {
$sideBar.affix({
offset: {
top: function () {
var offsetTop = $sideBar.offset().top
var sideBarMargin = parseInt($sideBar.children(0).css('margin-top'), 10)
var navOuterHeight = $('.bs-docs-nav').height()
return (this.top = offsetTop - navOuterHeight - sideBarMargin)
},
bottom: function () {
return $('.bs-footer').outerHeight(true)
}
}
})
}, 100)
$window.on('load resize', function () {
$body.scrollspy('refresh')
})
$window.on('load', function () {
$('.bs-top').affix();
setTimeout(function () {
$sideBar.affix('checkPosition')
}, 10);
});
// tooltip demo
$('.tooltip-demo').tooltip({
selector: "[data-toggle=tooltip]",
container: "body"
})
$('.tooltip-test').tooltip()
$('.popover-test').popover()
$('.bs-docs-navbar').tooltip({
selector: "a[data-toggle=tooltip]",
container: ".bs-docs-navbar .nav"
})
})
});
</script>
问题可能是由这个引起的:
【问题讨论】:
-
您是否查看过任何浏览器控制台,您的代码会抛出哪个错误?
-
错误信息说什么以及为什么 PHP 会与 jQuery 发生冲突?
-
php 不是这里的问题.. 除非您发现问题... 脚本可能... 这是控制台所说的 omarhabash.com/ss.png
标签: php jquery wordpress themes