Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Can't get jquery script to work.
New Landing › How can we help? › Themeforest Theme Support › Dante › Can't get jquery script to work.
- This topic has 16 replies, 3 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Dante
-
May 30, 2014 at 1:16 pm #79099
Hi guys,
I am terrible at javascript and jquery but I desperately need a special feature for my site so with a little help from google and after days of copy/pasting bits from the web I managed to get a functioning example of the feature I need.
The script’s purpose is to only show a specific part(height) of the description tab on the product page. If a visitor would like to read more about the product, he or she would only have to click on a button to expand the tab and read all available text in that tab. If the available text in the tab is less than the initial visible height of the tab (aka, not overflowing), then there will not be a button to click for expanding the tab.
This is very helpful if you are using tabs on product pages, you have a lot of text for description of the product and don’t want the product page to be 100 miles long because of all the text you have in the tab.
For a working example of my script, please visit: http://jsfiddle.net/gNsrG/305/Now to my problem: I can’t get it to work when I paste the script in “Custom JS” in admin. The tab (div) is set to the visible height it should be according to the CSS but there is no button under the tab to click on according to the jquery script.
Do you have any idea what might be causing this problem?
Kindest regards.May 31, 2014 at 10:41 am #79201Hi,
If you provide specific page url so i can debug to fix the issue very soon .
Thanks ๐
With Best Regards
Swift IdeasMay 31, 2014 at 12:29 pm #79207This reply has been marked as private.June 2, 2014 at 7:02 am #79426Hi,
I tried and could not resolve. Unfortunately that is not part of the current theme functionality, and it’s not within the scope of our support to be able to provide that functionality as it is more work than a small customisation. While we’d love to be able to support every customisation request, we simply don’t have the time. We recommend that you seek a freelance developer if you need that functionality, potentially from one of the below resources:Thanks ๐
With Best Regards
Swift IdeasJune 3, 2014 at 12:02 am #79679Hi @rixator
Is the code there now? had a quick look at front-end source and doesn’t seem like it’s begin outputted.
– Ed
June 3, 2014 at 7:07 am #79736Hi Ed,
That’s right. I put the code in the custom js part of admin but it is not being outputted in front-end.
Kind regards
June 3, 2014 at 8:03 am #79743Hi,
I have spent time and corrected code to work with theme so please check it now.
The corrected CSS code :.read-more { background: none repeat scroll 0 0 #E3E3E3; position: relative; text-align: center; top: -52px; width: 100%; cursor:pointer }
The corrected JS code:
<script> jQuery( document ).ready(function($) { $(".tabs li a").click(function() {var ahref=$(this).attr('href');console.log(ahref);if(ahref!='#tab-description'){$('div.read-more').hide();console.log('hide');}else{$('div.read-more').show();console.log('show');}}); $( "div.read-more" ).live( "click", function() { var thisText = $(this).text() ; if (thisText == 'Read more') { var curHeight = $('#tab-description').height(); $('#tab-description').css('height', 'auto'); var autoHeight = $('#tab-description').height(); $('#tab-description').css('height', curHeight + 'px'); $('#tab-description').animate({ 'height': autoHeight + "px" }, 600); $(this).text((thisText == 'Read more') ? 'Minimize' : 'Read more'); } else if (thisText == 'Minimize') { $('#tab-description').animate({ 'height': '150px' }, 300); $(this).text((thisText == 'Read more') ? 'Minimize' : 'Read more'); } return false; }); if ($('#tab-description')[0].scrollHeight > $('#tab-description').innerHeight()) { $('#tab-description').after('<div class="read-more" >Read more</div>'); } }); </script>
Thanks ๐
With Best Regards
Swift IdeasJune 3, 2014 at 2:05 pm #79847Fantastic!
Thank you very much for your help ๐June 3, 2014 at 2:05 pm #79848Hi,
You most welcome . I’m glad that issue resolved .
Thanks ๐
With Best Regards
Swift IdeasJune 19, 2014 at 3:01 pm #83832Hello again,
Thank you very much for your help last time.I encountered a few errors that I located to be a conflict with this script.
โข The search function is not accessible on any page other than product page.
โข On “My account” page the modal windows for email customer care and shipping information etc. darkens the entire page and nothing is clickable.I think that if the javascript only loads on the product pages then this issue will not appear.
Do you know if I can load the script only on product pages or do you think that the problem might be something else?Thank you.
Kindest regardsJune 20, 2014 at 7:15 am #83922Hi,
This script will not conflict with any script. YOu need to upgrade theme and plugins first. Hopefully that should fix your issues .
Thanks ๐
With Best Regards
Swift IdeasJune 22, 2014 at 10:04 am #84328Hi,
I have updated the theme and all plugins to the latest versions but the problem still exists.I thought that maybe I could keep the search box open as discussed in this thread but then I realized that the menu button that appears on smaller screens like on smartphones still would not work.
Do you have any other ideas on possible solutions?
Thank you.
June 23, 2014 at 7:28 am #84479Hi,
Have you made any changes beside it ?Thanks ๐
With Best Regards
Swift IdeasJune 25, 2014 at 10:34 am #85594Hi,
No I have not made any changes to the script.
Kind regards,
June 25, 2014 at 11:06 am #85614Hi,
I have resolved it so please check it now.
Thanks ๐
With Best Regards
Swift Ideas -
Posted in: Dante
You must be logged in and have valid license to reply to this topic.