我对html不太了解。但是由于某种原因,我使用 $(...) 之类的项目并不总是可以通过 web api 工作。如果我将我的项目离线并从我的系统运行它,它们就可以工作。
例子:
使用这个$('...').bind('dragstart'...)来移动窗口可以离线工作,但在 webapi 上,事件不会被捕获。
使用 $(document).ready(function () {似乎会导致查找引用出现问题。删除函数并且代码会找到引用。
使用 jqwidgets 此行无法触发 $("#jqxgrid").jqxGrid
我在这里完全没有想法,有什么想法吗?
在此处添加我的代码,因为注释不会提供足够的空间:
.html 文件
<!DOCTYPE html5>
<html lang="en">
<head>
<title>---</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href= "../../www/jQWidgets/jqwidgets/styles/jqx.base.css" type="text/css" />
<script type="text/javascript" src="../../www/jQWidgets/scripts/jquery-1.9.1.min.js" ></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxcore.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxdata.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxdata.export.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxbuttons.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxscrollbar.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxmenu.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxgrid.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxgrid.edit.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxgrid.selection.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxgrid.columnsresize.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/jqwidgets/jqxgrid.export.js"></script>
<script type="text/javascript" src="../../www/jQWidgets/scripts/gettheme.js"></script>
<script type='text/javascript' src='../../www/javascript/spreadSheet.js'></script>
<script type='text/javascript' src='../../www/javascript/dataLoader.js'></script>
<script type='text/javascript' src='../../www/javascript/windowMaker.js'></script>
<link href="../../www/window.css" rel="stylesheet" />
<style type="text/css" media="screen">
canvas, img { display:block; margin:1em auto; border:1px solid black; }
canvas { background:url(../../www/background.png) }
</style>
<script type="text/javascript">
var loadedData = loadData();
makeWindow();
function init()//this is called after the data is loaded. So hult all other action untill its read.
{
var data = loadedData[0].data.Name;
// makeSpreadSheet()
}
</script>
</head>
<body class='default'>
<div id="demo4_box" class="box message" data-minwidth="75" data-minheight="50">
<div id="bar" class="handle bar"><h2> window1</h2></div>
<div id="content" class="contents"><canvas id="canvas1" width="100" height="100"></canvas></div>
<div id="slider" class="handle resize">//</div>
</div>
<div id='jqxWidget'>
<div id="jqxgrid"></div>
<div style='margin-top: 20px;'>
<div style='float: left;'>
<input type="button" value="Export to Excel" id='excelExport' />
</div>
</div>
</div>
</body>
</html>
数据加载器js文件
function loadData()
{
var loadedData = new Array();
$document).ready(function () {
// Send an AJAX request
$.getJSON("api/DB/",
function (data) {
$.each(data, function (key, val) {
loadedData.push(val);
}); init();
});
});
return loadedData
}
窗口制造商js文件
function makeWindow( )
{
$(window).load(function () {
$('#demo4_box').bind('dragstart', function (event) {
return $(event.target).is('.handle');
}).bind('drag', function (event) {
$(this).css({
top: event.offsetY,
left: event.offsetX
});
});
$(".resize").bind('dragstart', function (event) {
var $box = $(this).closest(".box");
$box.data("width", $box.width());
$box.data("height", $box.height());
$box.data("x", event.offsetX);
$box.data("y", event.offsetY);
}).bind("drag", function (event) {
var $box = $(this).closest(".box");
$box.width(Math.max($box.data("width") - $box.data("x") + event.offsetX, $box.data("minwidth")));
$box.height(Math.max($box.data("height") - $box.data("y") + event.offsetY, $box.data("minheight")));
});
});
}