javascript - ReferenceError: display is not defined -
i got 'referenceerror: display not defined' script link below.
<script type="text/javascript" src="catalog/view/javascript/jquery/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-1.8.16.custom.min.js"></script>
i replace them latest version 1.11.1 , tried
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
but still there reference error. should change display function(script):
function display(view) { if (view == 'list') { $('.product-grid').attr('class', 'product-list'); $('.product-list > div').each(function(index, element) { html = '<div class="left">'; var image = $(element).find('.image').html(); if (image != null) { html += '<div class="image">' + image + '</div>'; } html += '<div class="mask hide-phone">'; html += ' <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>'; html += ' <div class="compare">' + $(element).find('.compare').html() + '</div>'; html += '</div>'; html += ' <div class="name">' + $(element).find('.name').html() + '</div>'; html += ' <div class="description">' + $(element).find('.description').html() + '</div>'; var rating = $(element).find('.rating').html(); if (rating != null) { html += '<div class="rating">' + rating + '</div>'; } var price = $(element).find('.price').html(); if (price != null) { html += '<div class="price">' + price + '</div>'; } html += ' <div class="cart">' + $(element).find('.cart').html() + '</div>'; html += ' <div class="cart-phone show-phone hide-desktop hide-tablet">' + $(element).find('.cart-phone').html() + '</div>'; html += '</div>'; $(element).html(html); }); $('.display').html(' <div id="list_b"></div> <a id="grid_a" title="<?php echo $text_grid; ?>" onclick="display(\'grid\');"></a>'); $.totalstorage('display', 'list'); } else { $('.product-list').attr('class', 'product-grid'); $('.product-grid > div').each(function(index, element) { html = ''; var image = $(element).find('.image').html(); if (image != null) { html += '<div class="image">' + image + '</div>'; } html += '<div class="mask hide-phone">'; html += ' <div class="wishlist">' + $(element).find('.wishlist').html() + '</div>'; html += ' <div class="compare">' + $(element).find('.compare').html() + '</div>'; html += '</div>'; html += '<div class="name">' + $(element).find('.name').html() + '</div>'; html += '<div class="description">' + $(element).find('.description').html() + '</div>'; var rating = $(element).find('.rating').html(); if (rating != null) { html += '<div class="rating">' + rating + '</div>'; } var price = $(element).find('.price').html(); if (price != null) { html += '<div class="price">' + price + '</div>'; } html += '<div class="cart">' + $(element).find('.cart').html() + '</div>'; html += ' <div class="cart-phone show-phone hide-desktop hide-tablet">' + $(element).find('.cart-phone').html() + '</div>'; $(element).html(html); }); $('.display').html(' <a id="list_a" title="<?php echo $text_list; ?>" onclick="display(\'list\');"><?php echo $text_list; ?></a> <div id="grid_b"></div>'); $.totalstorage('display', 'grid'); } } view = $.totalstorage('display'); if (view) { display(view); } else { display('list'); }
you can see conactenation creating issues:
copied source of link
html += ' <div class="cart" > ' + $(element).find('.cart').html() + '</div>';
at line div having newline character. may caused else can this:
html += ' <div class="cart">' + $(element).find('.cart').html() + '</div>'; html += ' <div class="cart-phone show-phone hide-desktop hide-tablet">' + $(element).find('.cart-phone').html() + '</div>'; html += '</div>';
here can see html+=' <div>'
line having space before div can remove it.
html += '<div class="cart">' + $(element).find('.cart').html() + '</div>'; html += '<div class="cart-phone show-phone hide-desktop hide-tablet">' + $(element).find('.cart-phone').html() + '</div>'; html += '</div>';
Comments
Post a Comment