From 82c29683d61b2e327d07183284648bd7c1c683f1 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Wed, 19 Mar 2014 11:06:18 +1100 Subject: [PATCH] Disabling enter on the search --- .../darkswarm/controllers/products_controller.js.coffee | 5 +++++ app/views/shop/shop/_products.html.haml | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee index 784aed539c..0a054d755d 100644 --- a/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/products_controller.js.coffee @@ -3,6 +3,11 @@ angular.module("Shop").controller "ProductsCtrl", ($scope, $rootScope, Product, $scope.order_cycle = OrderCycle.order_cycle Product.update() + $scope.searchKeypress = (e)-> + code = e.keyCode || e.which + if code == 13 + e.preventDefault() + $scope.productPrice = (product) -> if product.variants.length > 0 prices = (v.price for v in product.variants) diff --git a/app/views/shop/shop/_products.html.haml b/app/views/shop/shop/_products.html.haml index 22bc7c7933..9941dffad8 100644 --- a/app/views/shop/shop/_products.html.haml +++ b/app/views/shop/shop/_products.html.haml @@ -1,7 +1,9 @@ %products{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null"} = form_for :order, :url => populate_orders_path, html: {:class => "custom"} do - %input#search.text{"ng-model" => "query", placeholder: "Search"} + + %input#search.text{"ng-model" => "query", placeholder: "Search", "ng-keypress" => "searchKeypress($event)"} %input.button.right{type: :submit, value: "Add to Cart"} + %table %thead %th.name Item