javascript - Bigcommerce - Is it possible to change text after a function executes? -
i'm working on site right now, , there text want change. site has search feature in header, , after type 3 or 4 characters in input field, product list drops down listing products have characters in product name (similar to: http://www.lightexports.com/). want change text appears @ bottom of list, "view results".
i tried using .replace() function doesn't work, , can't use window.onload because if never use search, code never gets loaded on site. code display list of products , text want change appears after start typing in search bar.
**note: platform i'm using bigcommerce , allows html, css, , javascript.
any appreciated. in advance , happy coding!
i've figured out. best way7 accomplish this:
download quicksearch.js file loads on site -- queued in
snippets/quicksearchjs.html
, can download navigatingyourstore.com/javascript/quicksearch.js
.upload file webdav folder
/template/js/
in
snippets/quicksearchjs.html
snippet file, can edit bigcommerce backend "design > edit html/css" page, comment out original<script>
tag , add tag point js file uploaded webdav. newsnippets/quicksearchjs.html
file should this:<!-- <script type="text/javascript" src="%%global_cdnapppath%%/javascript/quicksearch.js?%%global_jscachetoken%%"></script> --> <script type="text/javascript" src="%%asset_js/quicksearch.js%%?%%global_jscachetoken%%"></script>
(yes, know syntax looks weird because of way asset used , way cachetoken must have %%. syntax correct.)
in quicksearch.js uploaded via webdav js folder, edit following lines, around lines 184-195:
if(all_results_count) { var tr = document.createelement('tr'); var td = document.createelement('td'); tr.classname = "quicksearchallresults"; tr.onmouseover = function() { quicksearch.over_all = true; }; tr.onmouseout = function() { quicksearch.over_all = false; }; td.colspan = 2; td.innerhtml = $('viewmoreurl', response).text(); tr.appendchild(td); popup.appendchild(tr); }
so this:
if(all_results_count) { var tr = document.createelement('tr'); var td = document.createelement('td'); tr.classname = "quicksearchallresults"; tr.onmouseover = function() { quicksearch.over_all = true; }; tr.onmouseout = function() { quicksearch.over_all = false; }; td.colspan = 2; td.innerhtml = 'your new custom text/name "view results" link goes here'; tr.appendchild(td); popup.appendchild(tr); }
put new name of "view results" link in between ' , ' @ line starts td.innerhtml =
- now save , refresh page, , text changed natively, without having write js , watch events or delegate actions.
please let me know if helped or if have questions.
Comments
Post a Comment