Button to trigger Ingredients?

Viewing 13 posts - 21 through 33 (of 33 total)
  • Author
    Posts
  • #17018
    Olly
    Admin & Mod

      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

      #17019
      manny
      Participant
        This reply has been marked as private.
        #17188
        manny
        Participant

          Hey 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

          #17193
          Olly
          Admin & Mod

            i 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

            #17194
            manny
            Participant

              Can 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?

              #17195
              Olly
              Admin & Mod

                >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/

                #17196
                Olly
                Admin & Mod
                  This reply has been marked as private.
                  #17197
                  Olly
                  Admin & Mod

                    maybe you should try closest('article').find.....etc

                    #17198
                    Olly
                    Admin & Mod

                      in fact, you are definitely using parent wrong. parent() does not take any arguments/elements

                      #17199
                      manny
                      Participant

                        Awesome 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?

                        #17200
                        Olly
                        Admin & Mod

                          >but I don’t think that would work in this case

                          ??? why wouldn’t it ???

                          #17201
                          manny
                          Participant

                            My 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”.

                            #17254
                            Olly
                            Admin & Mod

                              every article element has the appropriate post id

                            Viewing 13 posts - 21 through 33 (of 33 total)
                            • The topic ‘Button to trigger Ingredients?’ is closed to new replies.