Commit 46f7972285845bdf964edbf7ce9f0a1747ab0c4c
1 parent
c7b01ae4
Exists in
master
and in
29 other branches
Move JS code out of HTML template
Showing
2 changed files
with
14 additions
and
20 deletions
Show diff stats
plugins/shopping_cart/public/cart.js
| ... | ... | @@ -309,7 +309,20 @@ function Cart(config) { |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $(function(){ |
| 312 | - $('.cart-add-item').button({ icons: { primary: 'ui-icon-cart'} }) | |
| 312 | + | |
| 313 | + var profile = 'foo'; // FIXME | |
| 314 | + $.ajax({ | |
| 315 | + url: "/profile/" + profile + "/plugin/shopping_cart/get", | |
| 316 | + dataType: 'json', | |
| 317 | + success: function(data) { | |
| 318 | + new Cart(data); | |
| 319 | + $('.cart-add-item').button({ icons: { primary: 'ui-icon-cart'} }) | |
| 320 | + }, | |
| 321 | + cache: false, | |
| 322 | + error: function(ajax, status, errorThrown) { | |
| 323 | + alert('Error getting shopping cart - HTTP '+status+': '+errorThrown); | |
| 324 | + } | |
| 325 | + }); | |
| 313 | 326 | }); |
| 314 | 327 | |
| 315 | 328 | })(jQuery); | ... | ... |
plugins/shopping_cart/views/cart.html.erb
| ... | ... | @@ -15,22 +15,3 @@ |
| 15 | 15 | </a> |
| 16 | 16 | </div> |
| 17 | 17 | </div> |
| 18 | - | |
| 19 | -<script type="text/javascript"> | |
| 20 | -//<![CDATA[ | |
| 21 | - jQuery(function($) { | |
| 22 | - var profile = 'foo'; // FIXME | |
| 23 | - $.ajax({ | |
| 24 | - url: "/profile/" + profile + "/plugin/shopping_cart/get", | |
| 25 | - dataType: 'json', | |
| 26 | - success: function(data) { | |
| 27 | - new Cart(data); | |
| 28 | - }, | |
| 29 | - cache: false, | |
| 30 | - error: function(ajax, status, errorThrown) { | |
| 31 | - alert('Error getting shopping cart - HTTP '+status+': '+errorThrown); | |
| 32 | - } | |
| 33 | - }); | |
| 34 | - }); | |
| 35 | -//]]> | |
| 36 | -</script> | ... | ... |