• Daniel Iser

    (@danieliser)


    I’m working on Easy Modal trying to allow for unlimited modal windows to be created. For this to happen I need to be able to process each modals script separately with it’s chosen options.

    My question would be should I use php dynamic scripting with a doctype of JavaScript or create the script with some loops(which I’m not sure how to go about.) that will do similar to foreach in php.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Daniel Iser

    (@danieliser)

    Another method that might work which I just thought of would be to add 2 classes to the link for each modal.
    1. General class – eModal
    2. Modal specific – eModal-1 etc

    When a user clicks on object with class 1 jQuery detects class 2.

    I know I can then pass class 2 to my Ajax query but I’m at a loss to figure out how to pass other java specific settings like overlay colors. Callbacks etc back to the script after detection.

    I’m leaning towards using php to dynamically create the scripts for all the modals detected but I can already see flaws with this method that I would need to address.

    1. If user created 100 modals then the script could get potentially large.
    2. Cacheing issues with a dynamic scripts.

    Thread Starter Daniel Iser

    (@danieliser)

    Ok so after looking around the net for a few I’m wondering if this might work.
    On page load detect all modals and build a list.

    Call jQuery $.getScript to load the dynamic script with settings for the list of detected modals.

    Another option would be to create a single jQuery function with all option routes built in.
    Problem I’m trying to figure out there is how to get and pass the options to the function as each modal link will need to activate different options based on it’s second eModal class

    Maybe filter wp content and find all modal classes. Use this list to get each set of options and pass them via wp enqueue localized options?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Best method for dynamic script for plugin.’ is closed to new replies.