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(),