Consider the following case. We have an array with identical keys.
$arr = array(1 => 10, 1 => 11);
What happens when the interpreter reaches this line of code? This is not a syntax error and it is completely valid. Very similar, but more interesting case is when we have an array of identical keys, where those identical keys are represented once as an integer and then as a string.
In my last post from the event driven programming with jQuery series, I simply will post a sample application. In my previous post I showed up the use case for a tab panel, which can be done typically with no custom events, and almost every developer would do it that way, but however just for the purpose of this series I’ll separate the logic into two modules. One for the tabs and one for the content. Thus you can separate the application into two simple apps into two different pages, and they will continue to work correctly.
What is a module in one web page is may be not the correct question. Everything depends on how you understand the module. Let’s assume there is a tab panel on the page. This can be implemented simply by one UL and one DIV. In a sample app just clicking on a LI the the DIV content changes with appropriate content. Such tab panels can be seen almost on every site. See the homepage of Yahoo!. There are at least two tab panels, and to be exact every simple menu is like that, right? You click on an item and something on the page changes.
So a simple tab panel can be a single module and most often it is. But for this example let say the tab panel is composite of two modules. One for the UL > LI tabs and one for the DIV containing the dynamically loaded content.
The jQuery as usual simplifies the usage of this events and their handling. If you’ve some DOM with id ‘a’, i.e.:
document.getElementById('a').onclick = func();
In jQuery this comes with no browser dependencies, like:
That normally means that on click of that element, with id ‘a’, calls the func() method.
I’ll demonstrate in my next post how this can be implemented in a short example application.