Commit a5e93a0 Brett Wejrowski
committed
1 parent c1cd8f7 commit a5e93a0 Copy full SHA for a5e93a0
File tree 1 file changed +10
-7
lines changed
1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -753,7 +753,8 @@ function Shelf(){
753
753
if ( data [ 1 ] == "add" || data [ 1 ] == "Add" ) {
754
754
var tempArray = [ ] ;
755
755
tempArray . push ( node ) ;
756
- simpleCart . addEventToArray ( tempArray , simpleCart . Shelf . addToCart , "click" ) ;
756
+ var addFunction = simpleCart . Shelf . addToCart ( newItem . id ) ;
757
+ simpleCart . addEventToArray ( tempArray , addFunction , "click" ) ;
757
758
node . id = newItem . id ;
758
759
} else {
759
760
newItem [ data [ 1 ] ] = node ;
@@ -770,12 +771,14 @@ function Shelf(){
770
771
} ;
771
772
772
773
773
- Shelf . prototype . addToCart = function ( e ) {
774
- if ( ! e ) {
775
- e = window . event ;
776
- }
777
- var caller = e . target ? e . target : e . srcElement ;
778
- simpleCart . Shelf . items [ caller . id ] . addToCart ( ) ;
774
+ Shelf . prototype . addToCart = function ( id ) {
775
+ return function ( ) {
776
+ if ( simpleCart . Shelf . items [ id ] ) {
777
+ simpleCart . Shelf . items [ id ] . addToCart ( ) ;
778
+ } else {
779
+ error ( "Shelf item with id of " + id + " does not exist." ) ;
780
+ }
781
+ } ;
779
782
} ;
780
783
781
784
You can’t perform that action at this time.
0 commit comments