我正在以三种不同的方式动态更改我网站上的内容:
0) Reading json files via jQuery's getJSON('bla.json');
1) Retrieving jsonized C#/Razor classes via jQuery's getJSON('bla.cshtml');
2) Loading the html from a file via $('#divName').load('bla.html');
它们都工作正常,除了后者不装饰/spiffify 我的按钮。
我想可能是因为 HTML 文件不了解 jQuery 和 jQuery UI,所以我在页面顶部添加了这些行:
<link href="~/css/excite-bike/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="~/Scripts/jquery-ui-1.10.3.custom.min.js"></script>
……但这没什么区别。
要查看“现场”效果,请访问我的网站 www.awardwinnersonly.com - Books > Spurs (Westerns) 奖(刚刚开始 - 到目前为止只有一本书)是使用 Load('bla.html')方法; Hugos 使用 cshtml,所有其他人都在获取原始 json 文件。
以下是马刺队的全部代码:
HTML(我取出了上面显示的行,因为它们没有任何帮助):
<div class="yearBanner">2013</div><section class="wrapper" ><a id="mainImage" class="floatLeft" href="https://rads.stackoverflow.com/amzn/click/com/B0085DOE2O" rel="nofollow noreferrer"" target="_blank"><img height="160" width="107" src="http://images.amazon.com/images/P/B0085DOE2O.01.MZZZZZZZ.jpg"alt="Tucker's Reckoning by Ralph Compton and Matthew Mayo book cover"></img></a><div id="prizeCategory" class="category">Best Short Novel</div><br/><cite id="prizeTitle" >Tucker's
Reckoning</cite><br/><div id="prizeArtist" class="author">Ralph Compton and Matthew Mayo</div><br/><button><a href="https://rads.stackoverflow.com/amzn/click/com/B0085DOE2O" rel="nofollow noreferrer" target="_blank" rel="nofollow" >Kindle</a></button><button><a href="https://rads.stackoverflow.com/amzn/click/com/0451415612" rel="nofollow noreferrer" target="_blank"
rel="nofollow" >Hardcover</a></button><button><a href="https://rads.stackoverflow.com/amzn/click/com/0451465482" rel="nofollow noreferrer" target="_blank" rel="nofollow" >Paperback</a></button></section>
CSS:
.yearBanner {
font-size: 2em;
color: white;
font-family: 'Segoe UI Light', Candara, Calibri, Consolas, sans-serif;
width: 400px;
padding-top: 50px;
margin-left: 50px;
padding-bottom: 20px;
}
.floatLeft {
float: left;
padding-right: 10px;
padding-left: 5px;
}
section.wrapper {
/* this may need to be wider when landscape cover img is used */
min-width: 400px;
overflow: hidden;
display: block;
float: left;
margin-top: 5px;
}
.wrapper {
float: left;
width: 400px;
margin-left: 20px;
padding-bottom: 20px;
}
.category {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 2em;
color: Orange;
width: 160px;
}
.categorySmallerFont {
display: inline-block;
font-family: Consolas, sans-serif;
font-size: 1.5em;
color: Orange;
width: 160px;
}
cite {
display: inline-block;
font-family: Calibri, Candara, serif;
color: Yellow;
width: 160px;
}
.author, .artist, .person {
display: inline-block;
font-family: Courier, sans-serif;
font-size: 0.8em;
color: White;
width: 160px;
}
jQuery:
function getSpurs() {
$('#BooksContent').load('Content/spurFirstPage.html');
$('button').button();
var $largest = 0;
$(".wrapper").each(function () {
if ($(this).height() > $largest) {
$largest = $(this).height();
}
});
$(".wrapper").css("height", $largest);
}
我可以从我的 html 文件中引用 _SiteLayout.cshtml,或者如何将所需的 jQuery 主题合并到我的按钮中?