WPPizza – A Restaurant Plugin for WordPress › Support › Add-Ons › Extensions › Add Ingredients › Support › Button to trigger Ingredients?
- AuthorPosts
- 1 April, 2016 at 8:44 pm #17018
in fact, if you just want to add some link somewhere, then i dont really see the need for any of this and you just do an (parent)element>find > x > trigger> click without having to even worry about ids and whatnot
1 April, 2016 at 9:27 pm #17019This reply has been marked as private.7 April, 2016 at 6:51 pm #17188Hey Olly, can you see my last reply which I set to private? If not, here it is:
Hey Olly, I gave it a shot at trying to set up your solution from #17018, but I’m not getting it to work. Here’s what I have so far:
<script> jQuery(document).ready(function($) { $('.wppizza-article').append('<a>View Options</a>'); $('a#options').click(function() { $(this).parent('.wppizza-article').find('.wppizza-article-price').trigger("click"); console.log('clicked'); }); }); </script>
I’m getting “clicked” in the console, so it looks like it’s this line that I need to adjust:
$(this).parent('.wppizza-article').find('.wppizza-article-price').trigger("click");
Any ideas as to what’s wrong with that line? I can send you a link to the site if needed.
Cheers,
Manny
7 April, 2016 at 7:14 pm #17193i don’t know your site or where you are inserting your elements, but my guess is you are using
parent wrong
https://api.jquery.com/parent/except .parent() only travels a single level up the DOM tree
7 April, 2016 at 7:16 pm #17194Can you see my private reply? There’s a link to the site there. If not, can you send me your email so I can send you that link?
Anything else you think I should try?
7 April, 2016 at 7:26 pm #17195>Can you see my private reply
sure, but
a) i cannot see any “view options” anywhere
and
b) if you want to do / customise things that the plugin does not provide, then that’s something that you have to do yourself really.see also https://www.wp-pizza.com/topic/customisation/7 April, 2016 at 7:27 pm #17196This reply has been marked as private.7 April, 2016 at 7:34 pm #17197maybe you should try
closest('article').find.....etc
7 April, 2016 at 7:48 pm #17198in fact, you are definitely using parent wrong. parent() does not take any arguments/elements
7 April, 2016 at 8:19 pm #17199Awesome only, that worked! Only thing is, the View Options button is showing up on every menu item, even those without Ingredient options, which I’d like to remove. I know you mentioned a method on reply #17016, but I don’t think that would work in this case.
Any ideas?
7 April, 2016 at 8:28 pm #17200>but I don’t think that would work in this case
??? why wouldn’t it ???
7 April, 2016 at 9:13 pm #17201My bad Olly, I thought that solution was for a different JQuery implementation, not the one I’m using.
After taking another look though, it looks like it would work. So for example, one of the menu items that has ingredient options, has an id of wppizza-2035-0-0. I’m guessing I would need to add 2035 to the array of IDs, or can I just target those items using the full ID “wppizza-2035-0-0”?
I’m also guessing that I would need a for each loop, something like “if ID matches with ID from array, then go ahead and add the code to the menu item”.
8 April, 2016 at 10:56 pm #17254every article element has the appropriate post id
- AuthorPosts
- The topic ‘Button to trigger Ingredients?’ is closed to new replies.