Skip to contentSkip to conversation

toaster: tablejs Make sure click handlers consume click event

PATCH In review Michael Wood 2 participants 2 messages Nov 13, 2015 – Nov 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: tablejs Make sure click handlers consume click event

Avoid the click event from propagating and causing strange side effects in toaster tables.

[YOCTO #8527]
[YOCTO #8148]

---
 bitbake/lib/toaster/toastergui/static/js/table.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/static/js/table.js +6 -4
index 40b5022..c69c205 100644
@@ -340,7 +340,8 @@ function tableInit(ctx){
     }
   }
 
-  function sortColumnClicked(){
+  function sortColumnClicked(e){
+    e.preventDefault();
 
     /* We only have one sort at a time so remove any existing sort indicators */
     $("#"+ctx.tableName+" th .icon-caret-down").hide();
@@ -476,6 +477,7 @@ function tableInit(ctx){
   });
 
   $("#search-submit-"+ctx.tableName).click(function(e){
+    e.preventDefault();
     var searchTerm = $("#search-input-"+ctx.tableName).val();
 
     tableParams.page = 1;
@@ -489,8 +491,6 @@ function tableInit(ctx){
     }
 
     loadData(tableParams);
-
-    e.preventDefault();
   });
 
   $('.remove-search-btn-'+ctx.tableName).click(function(e){
@@ -514,7 +514,9 @@ function tableInit(ctx){
     e.preventDefault();
   });
 
-  $("#clear-filter-btn-"+ctx.tableName).click(function(){
+  $("#clear-filter-btn-"+ctx.tableName).click(function(e){
+    e.preventDefault();
+
     var filterBtn = $("#" + tableParams.filter.split(":")[0]);
     filterBtnActive(filterBtn, false);
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 5 lines · On 13/11/2015 14:33, "[email protected] on behalf of Michael…

Avoid the click event from propagating and causing strange side effects in toaster tables.

[YOCTO #8527]
[YOCTO #8148]

This definitely fixes 8527. I was never able to reproduce 8148, I'm afraid, but the sorting seems to be working for me with this patch.

Thanks!

Belén

Quoted 58 lines

---
bitbake/lib/toaster/toastergui/static/js/table.js | 10 ++++++----

1 file changed, 6 insertions(+), 4 deletions(-)
bitbake/lib/toaster/toastergui/static/js/table.js +2 -1
index 40b5022..c69c205 100644
@@ -340,7 +340,8 @@ function tableInit(ctx){
    }
  }
 
-  function sortColumnClicked(){
+  function sortColumnClicked(e){
+    e.preventDefault();
 
    /* We only have one sort at a time so remove any existing sort

indicators */

    $("#"+ctx.tableName+" th .icon-caret-down").hide();
bitbake/lib/toaster/toastergui/static/js/table.js +4 -3
@@ -476,6 +477,7 @@ function tableInit(ctx){
  });
 
  $("#search-submit-"+ctx.tableName).click(function(e){
+    e.preventDefault();
    var searchTerm = $("#search-input-"+ctx.tableName).val();
 
    tableParams.page = 1;
@@ -489,8 +491,6 @@ function tableInit(ctx){
    }
 
    loadData(tableParams);
-
-    e.preventDefault();
  });
 
  $('.remove-search-btn-'+ctx.tableName).click(function(e){
@@ -514,7 +514,9 @@ function tableInit(ctx){
    e.preventDefault();
  });
 
-  $("#clear-filter-btn-"+ctx.tableName).click(function(){
+  $("#clear-filter-btn-"+ctx.tableName).click(function(e){
+    e.preventDefault();
+
    var filterBtn = $("#" + tableParams.filter.split(":")[0]);
    filterBtnActive(filterBtn, false);
 
Signature · 7 lines
2.5.0

-- 
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster