Disabling enter on the search

This commit is contained in:
Will Marshall
2014-03-19 11:06:18 +11:00
parent 01503632f2
commit 82c29683d6
2 changed files with 8 additions and 1 deletions

View File

@@ -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)

View File

@@ -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