我目前使用AdminLTE模板创建管理页面。但是我遇到了包含jquery源代码的问题。我有一个函数的一部分是嵌套排序,它引用了jquery-1.7.2.min.js。它在Firefox中运行正常,但是当我尝试在谷歌浏览器中运行它时,我的侧边栏悬停功能不起作用。但是我试图替换原始模板jQuery,这是jQyery-2.0.2.min.js,之后我的悬停功能工作,但我的嵌套排序功能不再有效。我能做些什么来区分2个jQuery函数吗?
这是我的示例代码。我必须做我的嵌套排序功能:
<!-- Nested Sequence Reference-->
<script type="text/javascript" src="js2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js2/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js2/jquery.ui.touch-punch.js"></script>
<script type="text/javascript" src="js2/jquery.mjs.nestedSortable.js"></script>
<!-- Sequence Script-->
<script>
$(document).ready(function(){
$('ol.sortable').nestedSortable({
forcePlaceholderSize: true,
handle: 'div',
helper: 'clone',
items: 'li',
opacity: .6,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
maxLevels: 1,
isTree: false,
expandOnHover: 700,
startCollapsed: true
});
//Independent Content Sequence
$('#toIndependentHierarchy').click(function(e){
//hiered = $('ol.sortable').nestedSortable('toHierarchy', {startDepthCount: 0});
//hiered = dump(hiered);
//(typeof($('#toHierarchyOutput')[0].textContent) != 'undefined') ?
//$('#toHierarchyOutput')[0].textContent = hiered : $('#toHierarchyOutput')[0].innerText = hiered;
//Add to try the update the database function with jquery
serialized = $('ol.sortable').nestedSortable('serialize');
$.post( "independentBannerSequence.php", serialized, function( data ) {
alert( data );
});
return false;
})
//Master Content Sequence
$('#toMasterHierarchy').click(function(e){
//hiered = $('ol.sortable').nestedSortable('toHierarchy', {startDepthCount: 0});
//hiered = dump(hiered);
//(typeof($('#toHierarchyOutput')[0].textContent) != 'undefined') ?
//$('#toHierarchyOutput')[0].textContent = hiered : $('#toHierarchyOutput')[0].innerText = hiered;
//Add to try the update the database function with jquery
serialized = $('ol.sortable').nestedSortable('serialize');
$.post( "masterBannerSequence.php", serialized, function( data ) {
alert( data );
});
return false;
})
$('#toArray').click(function(e){
//arraied = $('ol.sortable').nestedSortable('toArray', {startDepthCount: 0});
arraied = $('ol.sortable').nestedSortable('toArray', {startDepthCount: 0});
arraied = dump(arraied);
(typeof($('#toArrayOutput')[0].textContent) != 'undefined') ?
$('#toArrayOutput')[0].textContent = arraied : $('#toArrayOutput')[0].innerText = arraied;
})
});
function dump(arr,level) {
var dumped_text = "";
if(!level) level = 0;
//The padding given at the beginning of the line.
var level_padding = "";
for(var j=0;j<level+1;j++) level_padding += " ";
if(typeof(arr) == 'object') { //Array/Hashes/Objects
for(var item in arr) {
var value = arr[item];
if(typeof(value) == 'object') { //If it is an array,
dumped_text += level_padding + "'" + item + "' ...\n";
dumped_text += dump(value,level+1);
} else {
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";
}
}
} else { //Strings/Chars/Numbers etc.
dumped_text = "===>"+arr+"<===("+typeof(arr)+")";
}
return dumped_text;
}
</script>
答案 0 :(得分:1)
尝试使用加载旧的jquery库动态,如果你使用firefox,并加载最新的jquery库就像使用chrome。
var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
// At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera; // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
How to detect Safari, Chrome, IE, Firefox and Opera browser?
答案 1 :(得分:0)
我通过使用jQuery-1.11.0.min.js版本解决了这个问题,其中google chrome和firefox都可用于我的悬停和排序嵌套函数。并且不要忘记粘贴
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
感谢所有帮助。非常感谢。