l33tspeak l33tspeak - 4 years ago 191
Javascript Question

How to initialize JQuery plugin?

I am trying to use this JQuery plugin.

I have all the JS and CSS files ready. The second step is as follows:


Then with simple initialization you have your pattern lock.

var lock = new PatternLock("#patternContainer");



Where do you do this initialization? Do I do this in a JS file, or in the coding of the page itself in a script (e.g. index.html)? I've been looking at other plugins and the instructions resemble these (in which you must initialize with a simple line).

Answer Source

You can do it in an inline script tag in the hmtl or in a script sourced from a separate file. Just so long as the script tag is after the ones it's dependent on (jquery and patternlock).

Then the line of code you're asking about initializes the plugin on an element in your html with the id="patternContainer" assuming you have such an element you should see results similar to the demos on the page you linked to.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download