From 246791751db33695dbc706086cc916293b517caf Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 20 Jun 2019 09:45:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B2=99=E7=AE=B1=E7=8E=AF?= =?UTF-8?q?=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sop-website/website-front/assets/js/inputcache.js | 2 +- .../website-front/pages/sandbox/sandbox.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sop-website/website-front/assets/js/inputcache.js b/sop-website/website-front/assets/js/inputcache.js index 50dbdd94..d9c24a26 100644 --- a/sop-website/website-front/assets/js/inputcache.js +++ b/sop-website/website-front/assets/js/inputcache.js @@ -8,7 +8,7 @@ var InputCache = { if (storage) { var dataKey = location.host; - $('body').find('input[type="text"]').unbind().change(function () { + $('body').on('change', 'input', function (){ var id = this.id; if (id) { var data = getCache(); diff --git a/sop-website/website-front/pages/sandbox/sandbox.js b/sop-website/website-front/pages/sandbox/sandbox.js index 386a7291..9f9c11a3 100644 --- a/sop-website/website-front/pages/sandbox/sandbox.js +++ b/sop-website/website-front/pages/sandbox/sandbox.js @@ -3,6 +3,8 @@ docEvent.bind(function (docItem,layui) { selectItem(docItem, layui); }); +InputCache.init(); + layui.use('form', function(){ var form = layui.form; @@ -15,14 +17,12 @@ layui.use('form', function(){ var $body = $('body'); var treetable; -var method,version; -var nameVersion; +var currentItem; function selectItem(docItem, layui) { + currentItem = docItem; resetResultDiv(); - nameVersion = docItem.nameVersion; - method = docItem.name; - version = docItem.version; + var nameVersion = docItem.nameVersion; treetable = treetable || layui.treetable; $('.sop-name').text(docItem.name); $('.sop-version').text(docItem.version); @@ -33,7 +33,6 @@ function selectItem(docItem, layui) { var $li = $('#docItemTree').find('li[nameversion="'+nameVersion+'"]'); $li.addClass('layui-this').siblings().removeClass('layui-this'); - InputCache.init(); } function createRequestParameter(docItem) { @@ -77,7 +76,7 @@ function createTreeTable(id, data) { cols: [[ {field: 'name', title: '参数',width: 200} ,{field: 'val', title: '值', width: 300, templet:function (row) { - var id = nameVersion + '-' + row.name; + var id = currentItem.nameVersion + '-' + row.name; var requiredTxt = row.required ? 'required lay-verify="required"' : ''; return !row.refs ? '' : ''; }} @@ -87,6 +86,8 @@ function createTreeTable(id, data) { } function doTest() { + var method = currentItem.method; + var version = currentItem.version; var data = { appId: $('#appId').val(), privateKey: $('#privateKey').val(),