0

I am trying to do a trigger when a function is called. If a page is called (www.example.com/search) i wanted to see if a valid param was passed with it. If it is it will trigger a click event to load that pages data, however it does not seem to click. I tested the loop and everything is fine. Just the final event will not click the link. Can anyone see any issues?

// the valid pages this can be used with
var valid_pages = ["search", "users"];

//the valid final param that can be used to make a click
var valid_params = ["menu", "deals", "reviews", "uploads", "activity", "followers", "following"];


if (inArray(page_param, valid_pages) === true) {

    //if the final param in the url string is valid then simulate the click event
    if (inArray(url_element, valid_params) === true) {

        //loop over the menu buttons
        $('.menu_button').each(function () {

            //if there is a valid url element click its link
            if ($(this).data("link-command") == url_element) {

                    $(this).trigger("click");
            }

        });
    }

}

0 Answers0