From df1704ef911847d4e390d1cde0cc80c35a19cbbe Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Thu, 19 Nov 2015 10:34:12 +0100 Subject: Use preventDefault instead of return false for link events --- js/codeq/language.js | 7 +++---- js/codeq/problem_list.js | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'js/codeq') diff --git a/js/codeq/language.js b/js/codeq/language.js index e86b09e..97691e6 100644 --- a/js/codeq/language.js +++ b/js/codeq/language.js @@ -9,15 +9,14 @@ jqRobot = $('#choose-robot'), choose = function (language) { codeq.globalStateMachine.transition('problem_list', language); - return false; }; codeq.globalStateMachine.register('language',{ 'enter': function(){ jqScreen.css('display', ''); - jqProlog.on('click', function () { return choose('prolog') }); - jqPython.on('click', function () { return choose('python') }); - jqRobot.on('click', function () { return choose('robot') }); + jqProlog.on('click', function (e) { e.preventDefault(); choose('prolog') }); + jqPython.on('click', function (e) { e.preventDefault(); choose('python') }); + jqRobot.on('click', function (e) { e.preventDefault(); choose('robot') }); }, 'exit' : function(){ jqProlog.off(); diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js index cc9e716..3fb9653 100644 --- a/js/codeq/problem_list.js +++ b/js/codeq/problem_list.js @@ -251,12 +251,13 @@ var language = data.language; jqScreen.html(data.html); codeq.tr.translateDom(jqScreen); - jqScreen.find('a').on('click', function () { + jqScreen.find('a').on('click', function (e) { var index = +$(this).attr('class').split(' ')[0].split('-')[1], ref = data.refs[index]; + e.preventDefault(); if (!ref) { codeq.log.error('Clicked on a problem link having erroneous index: ' + index); - return false; + return; } codeq.wait( Q.all([ @@ -274,7 +275,6 @@ alert('Failed to obtain the problem definition: ' + reason); }) .done(); - return false; }); }, -- cgit v1.2.1