[jQuery] Plugin understanding question
Hi,
I've come to a situation of making one .js file for many pages.
So, some pages have certain divs and some don't.
My situation is that whenever a plugin was defined for a certain div
in a certain page,
I seem to see it being invoked even on pages that don't have that div.
For example if page.html has a div called : <div id="page"><div
class="a"></div></div>
In a .js file I call: $('#page .a').plugin(); (let's say it does
alert('hi'); )
But on page2.html, I would see that plugin get invoked anyways, and a
message box would say 'hi'.
page2.html doesn't have <div id="page">. It only has <div id="page2">
This causes a problem because I have to constantly manually check if
all components needed for a plugin
are there on the page, which I think the selector - plugin call line
should automatically handle.
Can anyone help me, or has anyone had the same situation?
Thanks,
Seungjin Kim