Tagged: jQuery
-
AuthorPosts
-
September 22, 2015 at 1:34 pm #507014
Enfold v3.3.2 using child theme
Hello,
Please assist me to add click event handlers to the Pigments and Additives tabs in the Concrete and Asphalt sections of my development site.
I require the handlers to run some jquery that changes the background image of the associated color section above. I have 4 images, concrete_p.jpg, concrete_a.jpg, asphalt_p.jpg, asphalt_a.jpg.I have tried adding some code (/js/mcl.js) that tests the click event trigger, but this did not work.
Thanks.
Michael Jones
Micco Computing LimitedSeptember 22, 2015 at 2:43 pm #507075Hi _micco!
did you use the code block element to include your click event? I think you could try to activate debug mode and include the shortcode of your code block element somehow as image link. Maybe it will work for you.
Cheers!
AndySeptember 23, 2015 at 6:19 pm #508039Hello Andy,
I’ve put the click function attach code in script file ‘/js/mcl.js’. This has been registered and queued correctly.
To test the jQuery operation I inserted a code block above the Concrete section tab control. It contains the code below:
<style type=”text/css”> .code-block-div { color: yellow; background-color: blue; } </style>
<div id=”code-block-div” class=”code-block-div”>click this div for an alert box</div>In my script file I have a click function bound to ID #code-block-div, this just pops up an alert box. THIS WORKS.
I also have similar click functions bound to IDs #concrete-pigments-tab and #concrete-additives-tab but these do not trigger. These ID’s are the data-fake-id type. Is this causing the issue?As a further test, I wrapped the tab title for Additives in a div with ID #code-block-div as follows <div id=”code-block-div”>Additives</div>, this also did not work.
I know the jQuery attach mechanism works but not for the tab control.Please could you look into this as I don’t know your code well enough to diagnose this myself.
Regards,
MichaelSeptember 24, 2015 at 9:24 am #508224Hi,
Could you please provide us with a temporary admin login so that we can take a closer look? You can post the details in the Private Content section of your reply.
Regards,
RikardSeptember 24, 2015 at 10:18 am #508250Hello Rikard,
Login details as requested.
Michael
September 25, 2015 at 6:32 am #508774Hey!]
I’m sorry but I’m not sure how the script is suppose to work. Can you please create a html test page so that we can get a better idea? What is the selector that use in the click event? If you’re trying to target the tab title, try this for example:
div[data-fake-id="#asphalt-pigments-tab"]
Regards,
IsmaelSeptember 25, 2015 at 11:16 am #508911Hello Ismael,
I made a change to the site to show my requirement.
In the Concrete section I have added two clickable divs, one for Pigments (blue background) and one for additives (red background), If you click the divs, the background image in the color section above the divs changes.
I want the same effect when the Pigments or Additives tab title is clicked.
It would appear that the click functions are not bound correctly for tab titles or something is preventing the trigger. Please view script file /js/mcl.js to see the binds I have tried and investigate the issue.
Regards,
MichaelSeptember 26, 2015 at 10:26 am #509436Hi!
Did you try the selector above? For the “Additives” title, try this:
div[data-fake-id="#concrete-additives-tab"]
We have to access the js file via FTP. Please post the ftp details as well.
Cheers!
IsmaelSeptember 29, 2015 at 2:57 pm #510772Hello Ismael,
I tried the selector you provided, it didn’t work.
Selectors tested include:
jQuery(‘#concrete-pigments-tab’).click(function() {
jQuery(‘div[data-fake-id=”#concrete-pigments-tab”]’).click(function() {
jQuery(‘.tab_counter_0’).click(function() {In the Concrete section, I’ve changed the clickable divs for Enfold buttons. These change the color section background as required.
The site is scheduled to go live on Thursday so I would appreciate a resolution soon. Thanks.Michael
September 30, 2015 at 5:48 am #511113Hi!
Ignore my last post, I didn’t notice the ftp details in your last reply. We’ll give you an update after we check the scripts.
Regards,
IsmaelSeptember 30, 2015 at 6:20 am #511121Hi!
We transferred the code on functions.php file. You can check the page now (make sure you’re not looking on a cached version): http://procter.micco.co.uk/#asphalt-pigments-tab
EDIT: The image http://procter.micco.co.uk/wp-content/uploads/2015/09/asphalt_p.jpg and http://procter.micco.co.uk/wp-content/uploads/2015/09/asphalt_a.jpg are the same.
Regards,
IsmaelSeptember 30, 2015 at 11:39 am #511350Hi Ismael,
Thanks !!!!!!!!
Yes, the asphalt images are the same, I’m waiting for the new image from the design agency.
Why didn’t the code work in a separate javascript file?
I’m testing the site on an Android tablet and the section background doesn’t change like it does on a computer browser. Also the image sliding doesn’t work the same as a computer browser, they appear fixed. Is this expected?Michael
October 1, 2015 at 1:17 am #511890Hey Michael!
On which browser (in Android) are you seeing these issues? please note that, at the moment we’re only supporting Chrome for Android.
Regards,
JosueJanuary 12, 2018 at 1:25 am #896370Hi,
I’m having the same issue. I’m trying to have tab titles trigger some jquery to no avail. I see above that Ismael provided some modified code to the OP to rectify the situation. Is it possible I could obtain that code so that tab title can trigger jquery?
thnx!January 16, 2018 at 12:11 am #897758Hi,
@waxingmedia: Please provide a link to the page with the tabs so that we can check it. What script are you trying to apply?Best regards,
IsmaelJanuary 16, 2018 at 1:42 am #897780Hi, Ismael
Thanks for the reply. The url is in the private content area. If you scroll down to the first tab area, you will see a “button” above the tabs. If you click that, the bg image on that wrapper div will change. that is the behavior that I want, however, I want each of the tabs “sensor”, “dashboard” and “engage” to trigger the jquery as well and change the bg image.
Below is the script I’m using. #testid is assigned to the small button above the tabs now and works fine. However, I also have #testid assigned to each of the tabs as well, but they don’t trigger the jquery. I’ve also tried targeting the fake-data-ids and even the unique classes., eg., .tab_counter_0 of each tab. Is there something I can change in tabs.php or a function I can add that will allow the tab divs to trigger the jquery? Any help would be appreciated!
thnx!
<script>
$(document).ready(function(){
$(“#testid”).click(function(){
$(“#services-tab-1”).css(‘background-image’, ‘url(http://www.whiskerlabs.com/wp-content/uploads/2018/01/photo-services-ee.jpg)’);
});
});
</script>January 16, 2018 at 2:53 am #897820Hi,
Did you try the following selector format?
div[data-fake-id="#sensor"] div[data-fake-id="#dashboard"] div[data-fake-id="#engage"]
Best regards,
IsmaelJanuary 16, 2018 at 8:43 am #897927Hi, Ismael
I tried that as well. Nothing that I target in a tab div works. As you can see below, I even hardcoded id'”testid” into tabs.php to no avail.thnx!
<div data-fake-id=”#sensor” id=”testid” class=”tab tab_counter_0″ itemprop=”headline”>SENSOR</div>
January 16, 2018 at 9:50 am #897950Hi, Ismael
Here is some further info. I’ve put a link to a codepen I created of my page (static html, of course) and if you click on the “sensor”, “dashboard” and “engage” tabs, I can get the bg image of the container div to change. However, when it’s the wordpress site, nothing in those tabs will trigger jQuery. Again, any insight would be appreciated!
thanks again!
January 17, 2018 at 2:57 am #898261Hi,
Another update that might help. I did this as a test. if you load the page and click any div on the page, the first tab area’s bg image will change. Any div except the divs that are the tab titles. e.g.
<div data-fake-id=”#sensor” class=”tab active_tab tab_counter_0″ itemprop=”headline”>SENSOR</div>
none of these divs will trigger the javascript. It’s like jquery doesn’t see them or recognize them as divs. try loading the page and clicking any div and the bg image will change. Then reload the page and click any of the tabs… nothing.this is the script I used for the test.
thnx!
<script>
$(document).ready(function(){
$(“div”).click(function(){
$(“#services-tab-1”).css(“background-image”, “url(http://www.whiskerlabs.com/wp-content/uploads/2018/01/photo-services-ee.jpg)”);
});
}); s
</script>January 17, 2018 at 7:26 am #898307Hi,
Thank you for the update.
Please create a new thread with the site url and the login credentials. We’ll check it there. Make sure that the Appearance > Editor panel is accessible.
Best regards,
IsmaelJanuary 17, 2018 at 9:22 am #898341Hi, Ismael
Thanks! I appreciate you guys looking into it. I’ve opened a new thread per your request with the login info. This is a staging version of the site.
thanks again!
- This reply was modified 6 years, 10 months ago by waxingmedia.
January 18, 2018 at 8:39 am #898923Hi waxingmedia,
I just replied to you in that other thread.
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.