Trigger button function on page load based on url variable

Trigger button function on page load based on url variable

bfarkasbfarkas Posts: 181Questions: 48Answers: 0

I’m trying to think of a way to automatically trigger a button function when the user is brought to the data tables page. The idea is two user workflows:
1. New user: a custom button that launches a modal window with three fields to set first should be triggered on page load.
2. Returning user: the import CVS dialog should trigger so they can bring in their data file and start again.

I’m thinking url variables are the way to go, something like www.table.com?user=new

Any thoughts or different approach?

Replies

  • bfarkasbfarkas Posts: 181Questions: 48Answers: 0

    Closing this, the method described worked pretty well. In my case I just have it search for the string in the URL and then trigger the button for the function I want immediately.

    $(document).ready(function() {
        if (window.location.search == "?new") {
        p200table.button( '6-0' ).trigger();
        }
        if (window.location.search == "?return") {
        p200table.button( 7 ).trigger();
        }
        });
    
    
  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Agreed - I think that's probably the best way to do it.

    Allan

This discussion has been closed.