我正在为我的网站编写一个无限滚动的脚本:
$(window).scroll(function(){
if($(window).scrollTop() == $(document).height() - $(window).height()){
...
$.ajax({
...
success: function(json) {if(json.success){
...
// here I append an Ajax @response with a new element to my existing HTML
$("#mindIndexSummaryFirst").append(json.items1);
$("#mindIndexSummarySecond").append(json.items2);
$("#mindIndexSummaryThird").append(json.items3);
// here I try to check whether all images are loaded
$("#mindIndexSummary img").on('load', function(){
// and I need to call two functions on loaded element
// hoverImg() need the loaded image to calculate the height
$('.pi-hover-img'+json.course).hoverImg();
$(".popup3").tooltip();
});
}
...
});
Run Code Online (Sandbox Code Playgroud)
加载的 HTML 元素是这样的:
<div class="page-item pi-hover-img pi-normal"> …Run Code Online (Sandbox Code Playgroud) 在Laravel文档中,关于路由标题,在解释如何创建csrf标记的位置,文档说:
// Vanilla PHP
<?php echo csrf_field(); ?>
// Blade Template Syntax
{{ csrf_field() }}
Run Code Online (Sandbox Code Playgroud)
对Vanilla PHP意味着什么?预先感谢!:)
我以这种方式安装和配置了 jQuery dataTables 插件:
$locale = '意大利语'; 来自官方数据表网站
$( document ).ready(function() {
$(function () {
$('.data-table').dataTable({
"language": {
"url": '<?php echo asset_path("js/datatables/i18n/{$locale}.lang") ?>'
},
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
filter: true,
sort: true,
info: true,
autoWidth: true,
order: [[ 0, "desc" ]],
aoColumnDefs: [
{ bSortable: false, "aTargets": [ -1 ] }
]
});
});
});
Run Code Online (Sandbox Code Playgroud)
我尝试用“oLanguage”和“sUrl”替换“language”参数,但无论我做什么,我仍然看到英文的dataTables消息。
....
"oLanguage": {
"sUrl": '<?php echo asset_path("js/datatables/i18n/{$locale}.lang") ?>'
},
....
Run Code Online (Sandbox Code Playgroud)
我想我做错了什么,也许我需要先初始化表,然后才调用语言,反之亦然,然后再获取语言翻译和设置数据表......如果有人可以的话,我对这个插件真的很陌生帮助我,这会很棒!