From 7fa8f1fa08ad2b6d9a898ebaadd2e00d9e2f86e4 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Fri, 5 Sep 2014 16:17:36 +0200 Subject: [PATCH] fix web2py.js with show_if and grid --- applications/admin/static/js/web2py.js | 7 +++++-- applications/examples/static/js/web2py.js | 7 +++++-- applications/welcome/static/js/web2py.js | 7 +++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/applications/admin/static/js/web2py.js b/applications/admin/static/js/web2py.js index e11610cb..4219060f 100644 --- a/applications/admin/static/js/web2py.js +++ b/applications/admin/static/js/web2py.js @@ -545,8 +545,11 @@ }; $('[data-show-trigger]', target).each(function () { var name = $(this).attr('data-show-trigger'); - if(!triggers[name]) triggers[name] = []; - triggers[name].push($(this).attr('id')); + // The field exists only when creating/editing a row + if ($('#' + name).length) { + if(!triggers[name]) triggers[name] = []; + triggers[name].push($(this).attr('id')); + } }); for(var name in triggers) { $('#' + name, target).change(show_if).keyup(show_if); diff --git a/applications/examples/static/js/web2py.js b/applications/examples/static/js/web2py.js index e11610cb..4219060f 100644 --- a/applications/examples/static/js/web2py.js +++ b/applications/examples/static/js/web2py.js @@ -545,8 +545,11 @@ }; $('[data-show-trigger]', target).each(function () { var name = $(this).attr('data-show-trigger'); - if(!triggers[name]) triggers[name] = []; - triggers[name].push($(this).attr('id')); + // The field exists only when creating/editing a row + if ($('#' + name).length) { + if(!triggers[name]) triggers[name] = []; + triggers[name].push($(this).attr('id')); + } }); for(var name in triggers) { $('#' + name, target).change(show_if).keyup(show_if); diff --git a/applications/welcome/static/js/web2py.js b/applications/welcome/static/js/web2py.js index e11610cb..4219060f 100644 --- a/applications/welcome/static/js/web2py.js +++ b/applications/welcome/static/js/web2py.js @@ -545,8 +545,11 @@ }; $('[data-show-trigger]', target).each(function () { var name = $(this).attr('data-show-trigger'); - if(!triggers[name]) triggers[name] = []; - triggers[name].push($(this).attr('id')); + // The field exists only when creating/editing a row + if ($('#' + name).length) { + if(!triggers[name]) triggers[name] = []; + triggers[name].push($(this).attr('id')); + } }); for(var name in triggers) { $('#' + name, target).change(show_if).keyup(show_if);