From c7e55b476570862b74b9aeafbe2d7576466083fe Mon Sep 17 00:00:00 2001 From: priscilla0123 <823841737@qq.com> Date: Thu, 9 Mar 2017 16:04:29 +0800 Subject: [PATCH] Update index.js --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index bc07e8d..a3cbe1a 100644 --- a/index.js +++ b/index.js @@ -45,9 +45,10 @@ function now(){ return (new Date).getTime(); } -function Quickling(selector, container){ +function Quickling(selector, container,option){ var self = this; + self.option=option?option:{}; self.selector = selector; self.container = $(container)[0]; self.expires = 0; @@ -122,6 +123,9 @@ Quickling.prototype = { self.isForce = false; self.loader = Pagelet.load(url, function(data, status){ self.loader = null; + if(self.option.beforeRender&&self.option.beforeRender(data,status)==false){ + return; + } Pagelet.append(self.container, data); self.caches[url] = {data: data, time: now()}; self.trigger('send:back', [data, status]); @@ -164,12 +168,13 @@ Quickling.prototype = { var instance; -return function(className, container){ +return function(className, container,option){ if(instance){ return instance; } - return instance = new Quickling(className, container); + return instance = new Quickling(className, container,option); }; }); +