插件 jQuery Ajaxify 中文API文档
插件 jQuery.Ajaxify 中文API文档
源码 & 下载
- Github地址:https://github.com/arvgta/ajaxify
- 源码下载: -
- 效果演示: -
适用场景
在几分钟内对您的网站进行Ajax化
大多数网站具有以下页面结构:
- Header
- Sidebar(s)
- Content
- Footer
…只有少数元素差别很大。
避免整页刷新和相关的完整往返并创建令人敬畏的页面加载时间。
当ajaxifying一个站点时,必须考虑这个插件所涉及的一些事情…所以它是一个完整的Ajax框架!
插件特点
基本用法
将以下代码放在您喜欢的任何位置
$(document).ready(function(){ jQuery(’#content’).ajaxify();});
对整个网站进行Ajax化,在页面中使用
如果要交换多个元素,只需指定它们的ID,如下所示:
jQuery('#nav, #content').ajaxify();
该插件可以使用任意数量的ID。根据DOM中的顺序,选择中的最后一个元素是默认的主要内容元素。
设置maincontent
您可以通过指定eg来覆盖主要内容元素
maincontent: "#content"
如果主要内容元素不是选择的最后/唯一元素,那么这甚至是强制性的。
设置alwayshints
从版本7.2.0开始,您必须通过设置 alwayshints
或 data-class ='always'
指定每次要加载的文件
公共方法
以编程方式跳转到内部页面:
jQuery().ajaxify(URL);
例如
- jQuery().ajaxify(“http://mysite.com/about");
访问主要内容div
- jQuery.cd(“g”);
访问$ .ajax()调用的XHR对象
- jQuery.getPage(“x”);
官方介绍
源码解析
选项默认值
{
/* basic config parameters */
selector : "a:not(.no-ajaxy)", //Selector for elements to ajaxify - without being swapped - e.g. a selection of links
maincontent : false, //Default main content is last element of selection, specify a value like "#content" to override
forms : "form:not(.no-ajaxy)", // jQuery selection for ajaxifying forms - set to "false" to disable
canonical : true, // Fetch current URL from "canonical" link if given, updating the History API. In case of a re-direct...
refresh : false, // Refresh the page if clicked link target current page
/* visual effects settings */
requestDelay : 0, //in msec - Delay of Pronto request
aniTime : 0, //in msec - must be set for animations to work
aniParams : false, //Animation parameters - see below. Default = off
previewoff : true, // Plugin previews prefetched pages - set to "false" to enable or provide a jQuery selection to selectively disable
scrolltop : "s", // Smart scroll, true = always scroll to top of page, false = no scroll
bodyClasses : false, // Copy body classes from target page, set to "true" to enable
idleTime: 0, //in msec - master switch for slideshow / carousel - default "off"
slideTime: 0, //in msec - time between slides
menu: false, //Selector for links in the menu
addclass: "jqhover", //Class that gets added dynamically to the highlighted element in the slideshow
/* script and style handling settings, prefetch */
deltas : true, // true = deltas loaded, false = all scripts loaded
asyncdef : false, // default async value for dynamically inserted external scripts, false = synchronous / true = asynchronous
alwayshints : false, // strings, - separated by ", " - if matched in any external script URL - these are always loaded on every page load
inline : true, // true = all inline scripts loaded, false = only specific inline scripts are loaded
inlinehints : false, // strings - separated by ", " - if matched in any inline scripts - only these are executed - set "inline" to false beforehand
inlineskip : "adsbygoogle", // strings - separated by ", " - if matched in any inline scripts - these are NOT are executed - set "inline" to true beforehand
inlineappend : true, // append scripts to the main content div, instead of "eval"-ing them
style : true, // true = all style tags in the head loaded, false = style tags on target page ignored
prefetch : true, // Plugin pre-fetches pages on hoverIntent
/* debugging & advanced settings*/
verbosity : 0, //Debugging level to console: default off. Can be set to 10 and higher (in case of logging enabled)
memoryoff : false, // strings - separated by ", " - if matched in any URLs - only these are NOT executed - set to "true" to disable memory completely
cb : null, // callback handler on completion of each Ajax request - default null
pluginon : true // Plugin set "on" or "off" (==false) manually
}