1

I am trying to run a jQuery snippet after I initialize a custom jQuery plugin.

The snippet needs to modify part of the DOM that the plugin makes, so I need to ensure that the snippet executes after the plugin finishes initializing its DOM.

$(function() {
        // initializing the plugin
        PluginConstructor({
                "id": "plugin-container"
        });

        // snippet
        $('.some-div-inside-plugin-container').remove();    
});

The above seems to execute non-sequentially, top to bottom, since the snippet has no effect, leading me to believe the snippet was executed before the plugin's DOM has finished initializing.

Is there a jQuery/javascript method that allows the snippet to wait for the completion of the plugin?

I cannot modify the source code of the plugin, by the way.

4
  • And the plugin is.... ???? A phantom??? Maybe the plugin have got any event handler to manage this. Something like $('selector').on('plugin:ready') Commented Nov 3, 2015 at 17:26
  • Maybe, I will try to find out Commented Nov 3, 2015 at 17:27
  • If you don't specify to us what plugin is or what code do you are trying to use, this topic should be marked as should be closed, because too broad, unclear what you're asking, etc. Commented Nov 3, 2015 at 17:31
  • I was just wondering if there was an universal way of waiting for a constructor to finish Commented Nov 3, 2015 at 17:34

1 Answer 1

1

I think no, there's no jQuery/javascript method do that, because that depend to the plugin itself, so you have to check in the plugin you want to use for this function triggred after load (ready status).

Just like example @Marcos mentioned in comment for phantomJS we found onLoadFinished or onInitialized functions.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok I will try to find a similar on load finish method for the plugin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.