Bringing filter support to live method
One of my live methods was not working. So I started looking into the code without realizing that live does not support filter method.
Anyway I patched the code to make live support filter method. I am learning both JavaScript and jQuery and hence I am submitting it a bit hesitantly .
Here is my commit
Logic is simple. I am converting following selctor
- "#container a.filter(.top).filter(.first)"
to
- ['#container a', '.top', '.first']
using this regex
- matches = text.match(/^[^.]*|\.[^.)]*(?=\))/g);
I have not written any tests but if I am headed in the right direction then lemme know and I write write tests.
I tested my changes with following selectors.
- $('#container a').filter('.top').live('click', function(e){
- log( $(this).text() + ' clicked1');
- e.preventDefault();
- });
- $('#container a').filter('.top').live('click', function(e){
- log( $(this).text() + ' clicked2');
- e.preventDefault();
- });
- $('#container a').filter('.top').filter('.first').live('click', function(e){
- log( $(this).text() + ' first clicked');
- e.preventDefault();
- });
- $('#container a').filter('.bottom').live('click', function(e){
- log( $(this).text() + ' bottom clicked');
- e.preventDefault();
- });