Errors after converting a Rails application to use Jquery
I was using prototype with Rails 3 but i converted to jquery using:
rake rails:template LOCATION=http://github.com/lleger/Rails-3-jQuery/raw/master/jquery.rb
as suggested here https://github.com/lleger/Rails-3-jQuery
But after the conversion all the javascript seems broken I am getting errors like:
RJS error:
ReferenceError: $$ is not defined
AND then
$$("#notice").each(function(value, index) {
value.hide();
});
Element.update("cart", "<div class=\"cart_title\">Your Cart</div>\n<table>\n <tr id=\"current_item\">\n <td>3×</td>\n <td>Programming Ruby 1.9</td>\n <td class=\"item_price\">$148.50</td>\n</tr>\n\n\n <tr class=\"total_line\">\n <td colspan=\"2\">Total</td>\n <td class=\"total_cell\">$148.50</td>\n 开发者_JAVA技巧 </tr>\n\n</table>\n<!-- START_HIGHLIGHT -->\n<form method=\"get\" action=\"/orders/new\" class=\"button_to\"><div><input type=\"submit\" value=\"Checkout\" /></div></form>\n<!-- END_HIGHLIGHT -->\n<form method=\"post\" action=\"/carts/9\" class=\"button_to\"><div><input name=\"_method\" type=\"hidden\" value=\"delete\" /><input data-confirm=\"Are you sure?\" type=\"submit\" value=\"Empty cart\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"6rsfHAqN1+p/Hb5/9QNxSFpXqmknSuUG2QtglirA6UM=\" /></div></form>\n");
$("current_item").visualEffect("highlight", {"startcolor":"#88ff88","endcolor":"#114411"})
;
What can be the possible problem?
The problem I think is that the helpers which use scriptaculous get broken. Rails 3 helpers are using scriptaculous. What is the way out is the bigger question?
Those errors refer to functions that Prototype provides, but which jQuery doesn't. Simply put you still have javascript code that uses Prototype, which is now no longer provided, hence the errors.
精彩评论