[jQuery] Re: My first jQuery plugin
On Jul 18, 2008, at 9:13 AM, Mike Alsup wrote: Yes, Sam's selector will definitely stop climbing the DOM once it finds the first match. That's what the :eq(0) part does. Actually, I don't think that's true. I believe :first, :last, :eq, etc apply their logic after the list of potential elements has been built. The results are accurate of course, but I don't see where their is any optimizations for the :first or :eq cases to short- circuit the climb. Mike Ah, I see what you mean. I misunderstood what was actually meant by "stop climbing the DOM" and assumed he meant stop returning elements. Anyway, you're right. It won't return any of the other elements, but it *will* climb all the way up before it returns just the first match. Thanks for the clarification, Mike! --Karl Karl Swedberg www.englishrules.com www.learningjquery.com
[jQuery] Re: My first jQuery plugin
> Yes, Sam's selector will definitely stop climbing the DOM once it > finds the first match. That's what the :eq(0) part does. Actually, I don't think that's true. I believe :first, :last, :eq, etc apply their logic after the list of potential elements has been built. The results are accurate of course, but I don't see where their is any optimizations for the :first or :eq cases to short- circuit the climb. Mike
[jQuery] Re: My first jQuery plugin
Hi Pete, Yes, Sam's selector will definitely stop climbing the DOM once it finds the first match. That's what the :eq(0) part does. The :first selector does the same thing as :eq(0), so this would work equally as well: $("#myelement").parents("table:first") --Karl Karl Swedberg www.englishrules.com www.learningjquery.com On Jul 18, 2008, at 2:51 AM, ProggerPete wrote: Mmm tasty. That does look the goods. Do you know whether under the hood it is smart enough to stop climbing the DOM once it finds the 1st match? Cheers, Pete On Jul 17, 5:40 pm, Sam Collett <[EMAIL PROTECTED]> wrote: How about: $("#myelement").parents("table:eq(0)") Does that do what you want? Example:http://demos.texotela.co.uk/parents.html --Sam On Jul 17, 7:51 am, ProggerPete <[EMAIL PROTECTED]> wrote: Hi Andy, parents doesn't do quite what I want. I want a method I can use in event delegation handlers that basically says, 'Give me the nearest x element'. I could of course check the current element, if it doesn't match I could then do a parents and then work on the 1st result in that, but that would be a bunch of extra processing for no gain (while it continues to check parents that I have no interest in). I was more after info about any silly things I've done while implementing the function. I've since discovered pushStack which helps a fair bit. =) Cheers, Pete On Jul 15, 6:19 pm, "Andy Matthews" <[EMAIL PROTECTED]> wrote: Pete... There is a built in parent method which does pretty much what you're doing. http://remysharp.com/jquery-api/ Look under parents(). -Original Message- From: jquery-en@googlegroups.com [mailto:jquery- [EMAIL PROTECTED] On Behalf Of ProggerPete Sent: Tuesday, July 15, 2008 10:41 AM To: jQuery (English) Subject: [jQuery]MyfirstjQueryplugin Hi folks, I'm very new to jQuery and am playing around with what is possible. I found myself wanting a findParent function and couldn't spot one ready made. I'd love it if people could give me feedback onmyimplementation. I'm sure there's plenty I could do better. If this function also exists I'd like to know where it is too. =) /** * return thefirstparent that matches the selector. Optionally include the src element in the search */ $.fn.findParent = function() { var _this, _selector, _includeSelf, _result; function find(index, elem) { if (!_includeSelf) elem = elem.parentNode; while (elem) { if ($(elem).is(_selector)) return _result.push(elem); elem = elem.parentNode; } } function _findParent(selector, includeSelf) { var thisp = _this = this; _selector = selector; _includeSelf = includeSelf; _result = []; this.each(find); var retObj = $(_result); retObj.end = function () { return thisp }; return retObj; } return _findParent; }(); Cheers, Pete
[jQuery] Re: My first jQuery plugin
Mmm tasty. That does look the goods. Do you know whether under the hood it is smart enough to stop climbing the DOM once it finds the 1st match? Cheers, Pete On Jul 17, 5:40 pm, Sam Collett <[EMAIL PROTECTED]> wrote: > How about: > > $("#myelement").parents("table:eq(0)") > > Does that do what you want? > > Example:http://demos.texotela.co.uk/parents.html > > --Sam > > On Jul 17, 7:51 am, ProggerPete <[EMAIL PROTECTED]> wrote: > > > Hi Andy, > > parents doesn't do quite what I want. I want a method I can use in > > event delegation handlers that basically says, 'Give me the nearest x > > element'. I could of course check the current element, if it doesn't > > match I could then do a parents and then work on the 1st result in > > that, but that would be a bunch of extra processing for no gain (while > > it continues to check parents that I have no interest in). > > > I was more after info about any silly things I've done while > > implementing the function. I've since discovered pushStack which > > helps a fair bit. =) > > > Cheers, > > Pete > > > On Jul 15, 6:19 pm, "Andy Matthews" <[EMAIL PROTECTED]> wrote: > > > > Pete... > > > > There is a built in parent method which does pretty much what you're > > > doing. > > > >http://remysharp.com/jquery-api/ > > > > Look under parents(). > > > > -Original Message- > > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > > > > Behalf Of ProggerPete > > > Sent: Tuesday, July 15, 2008 10:41 AM > > > To: jQuery (English) > > > Subject: [jQuery]MyfirstjQueryplugin > > > > Hi folks, > > > I'm very new to jQuery and am playing around with what is possible. > > > > I found myself wanting a findParent function and couldn't spot one ready > > > made. I'd love it if people could give me feedback onmyimplementation. > > > I'm sure there's plenty I could do better. If this function also exists > > > I'd > > > like to know where it is too. =) > > > > /** > > > * return thefirstparent that matches the selector. Optionally include > > > the src element in the search */ $.fn.findParent = function() { > > > var _this, _selector, _includeSelf, _result; > > > > function find(index, elem) > > > { > > > if (!_includeSelf) elem = elem.parentNode; > > > while (elem) > > > { > > > if ($(elem).is(_selector)) return > > > _result.push(elem); > > > elem = elem.parentNode; > > > } > > > } > > > > function _findParent(selector, includeSelf) > > > { > > > var thisp = _this = this; > > > _selector = selector; > > > _includeSelf = includeSelf; > > > _result = []; > > > this.each(find); > > > var retObj = $(_result); > > > retObj.end = function () { return thisp }; > > > return retObj; > > > } > > > > return _findParent; > > > }(); > > > > Cheers, > > > Pete
[jQuery] Re: My first jQuery plugin
How about: $("#myelement").parents("table:eq(0)") Does that do what you want? Example: http://demos.texotela.co.uk/parents.html --Sam On Jul 17, 7:51 am, ProggerPete <[EMAIL PROTECTED]> wrote: > Hi Andy, > parents doesn't do quite what I want. I want a method I can use in > event delegation handlers that basically says, 'Give me the nearest x > element'. I could of course check the current element, if it doesn't > match I could then do a parents and then work on the 1st result in > that, but that would be a bunch of extra processing for no gain (while > it continues to check parents that I have no interest in). > > I was more after info about any silly things I've done while > implementing the function. I've since discovered pushStack which > helps a fair bit. =) > > Cheers, > Pete > > On Jul 15, 6:19 pm, "Andy Matthews" <[EMAIL PROTECTED]> wrote: > > > Pete... > > > There is a built in parent method which does pretty much what you're doing. > > >http://remysharp.com/jquery-api/ > > > Look under parents(). > > > -Original Message- > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > > > Behalf Of ProggerPete > > Sent: Tuesday, July 15, 2008 10:41 AM > > To: jQuery (English) > > Subject: [jQuery] My first jQuery plugin > > > Hi folks, > > I'm very new to jQuery and am playing around with what is possible. > > > I found myself wanting a findParent function and couldn't spot one ready > > made. I'd love it if people could give me feedback on my implementation. > > I'm sure there's plenty I could do better. If this function also exists I'd > > like to know where it is too. =) > > > /** > > * return the first parent that matches the selector. Optionally include > > the src element in the search */ $.fn.findParent = function() { > > var _this, _selector, _includeSelf, _result; > > > function find(index, elem) > > { > > if (!_includeSelf) elem = elem.parentNode; > > while (elem) > > { > > if ($(elem).is(_selector)) return > > _result.push(elem); > > elem = elem.parentNode; > > } > > } > > > function _findParent(selector, includeSelf) > > { > > var thisp = _this = this; > > _selector = selector; > > _includeSelf = includeSelf; > > _result = []; > > this.each(find); > > var retObj = $(_result); > > retObj.end = function () { return thisp }; > > return retObj; > > } > > > return _findParent; > > }(); > > > Cheers, > > Pete
[jQuery] Re: My first jQuery plugin
Hi Andy, parents doesn't do quite what I want. I want a method I can use in event delegation handlers that basically says, 'Give me the nearest x element'. I could of course check the current element, if it doesn't match I could then do a parents and then work on the 1st result in that, but that would be a bunch of extra processing for no gain (while it continues to check parents that I have no interest in). I was more after info about any silly things I've done while implementing the function. I've since discovered pushStack which helps a fair bit. =) Cheers, Pete On Jul 15, 6:19 pm, "Andy Matthews" <[EMAIL PROTECTED]> wrote: > Pete... > > There is a built in parent method which does pretty much what you're doing. > > http://remysharp.com/jquery-api/ > > Look under parents(). > > -Original Message- > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > > Behalf Of ProggerPete > Sent: Tuesday, July 15, 2008 10:41 AM > To: jQuery (English) > Subject: [jQuery] My first jQuery plugin > > Hi folks, > I'm very new to jQuery and am playing around with what is possible. > > I found myself wanting a findParent function and couldn't spot one ready > made. I'd love it if people could give me feedback on my implementation. > I'm sure there's plenty I could do better. If this function also exists I'd > like to know where it is too. =) > > /** > * return the first parent that matches the selector. Optionally include > the src element in the search */ $.fn.findParent = function() { > var _this, _selector, _includeSelf, _result; > > function find(index, elem) > { > if (!_includeSelf) elem = elem.parentNode; > while (elem) > { > if ($(elem).is(_selector)) return > _result.push(elem); > elem = elem.parentNode; > } > } > > function _findParent(selector, includeSelf) > { > var thisp = _this = this; > _selector = selector; > _includeSelf = includeSelf; > _result = []; > this.each(find); > var retObj = $(_result); > retObj.end = function () { return thisp }; > return retObj; > } > > return _findParent; > }(); > > Cheers, > Pete
[jQuery] Re: My first jQuery plugin
Pete... There is a built in parent method which does pretty much what you're doing. http://remysharp.com/jquery-api/ Look under parents(). -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of ProggerPete Sent: Tuesday, July 15, 2008 10:41 AM To: jQuery (English) Subject: [jQuery] My first jQuery plugin Hi folks, I'm very new to jQuery and am playing around with what is possible. I found myself wanting a findParent function and couldn't spot one ready made. I'd love it if people could give me feedback on my implementation. I'm sure there's plenty I could do better. If this function also exists I'd like to know where it is too. =) /** * return the first parent that matches the selector. Optionally include the src element in the search */ $.fn.findParent = function() { var _this, _selector, _includeSelf, _result; function find(index, elem) { if (!_includeSelf) elem = elem.parentNode; while (elem) { if ($(elem).is(_selector)) return _result.push(elem); elem = elem.parentNode; } } function _findParent(selector, includeSelf) { var thisp = _this = this; _selector = selector; _includeSelf = includeSelf; _result = []; this.each(find); var retObj = $(_result); retObj.end = function () { return thisp }; return retObj; } return _findParent; }(); Cheers, Pete
[jQuery] Re: My First jQuery Plugin..... jQuery.Sheet, a spreadsheet for jQuery
nice work. a good start select rows or cols - and be able to copy (just them to copypaste) shift clicking sorting (excel can exclude header cells) double click to edit in place (I see you can put the value in the top, but that alot of backward and forewards with the mouse) transform cell referances to uppercase On 19/12/2007, Robert-CFL <[EMAIL PROTECTED]> wrote: > > > Here is a link to a running version of the plugin: > http://www.weebly.com/uploads/3/1/3/8/313814/jquery.sheet.html > > On Dec 19, 3:02 pm, Robert-CFL <[EMAIL PROTECTED]> wrote: > > Actually, I thank you for the criticism. The reason that I went ahead > > and posted it was because it is (in reality) past a beta state in that > > it works and at TrimPath it's in version 1.0.14. It's in beta in my > > eyes because I'm porting it over from standard JavaScript and the > > additional jQuery functionality. I'm sure in the future this project > > will advance much. And as far as having a demo, I will have one up > > shortly. I honestly have had very limited time to work on this > > project. Bare with me guys :). > > > > On Dec 18, 5:36 pm, Shawn <[EMAIL PROTECTED]> wrote: > > > > > Sounds like a good plugin, but may I offer a couple of suggestions? > > > > > 1. Post a demo of the plugin. I don't have time to download and setup > > > all the plugins I might potentially want to use. A quick sample takes > > > me seconds to make that evaluation, rather than 30+ minutes to go > > > through a setup area. > > > > > 2. I don't mean to curb your enthusiasm, but I have a problem with > 0.01 > > > releases getting posted to the plugins page. As a developer looking > for > > > a solution, I'm looking for something that is at least mature enough > to > > > be considered stable. a 0.01 version is still beta (to me at > least). I > > > can't bash you tooo hard on this though - I have my own plugin posted > on > > > my site at a 0.01 version. But I wouldn't dream of posting this to > > > plugins.jquery.com at this time. :) > > > > > I'm interested to see where your plugin goes. I can see a lot of > > > potential for a spreadsheet like grid. > > > > > Shawn > > > > > Robert-CFL wrote: > > > > I know there's not to much content, but let me know if you want to > > > > help out with this plugin. it has GREAT possibilities. I know alot > > > > > of people have been looking for something like this. let me know > what > > > > you guys think. > > > > > > I'll work on documentation when i get time. > > > > > > http://plugins.jquery.com/project/Sheet >
[jQuery] Re: My First jQuery Plugin..... jQuery.Sheet, a spreadsheet for jQuery
Here is a link to a running version of the plugin: http://www.weebly.com/uploads/3/1/3/8/313814/jquery.sheet.html On Dec 19, 3:02 pm, Robert-CFL <[EMAIL PROTECTED]> wrote: > Actually, I thank you for the criticism. The reason that I went ahead > and posted it was because it is (in reality) past a beta state in that > it works and at TrimPath it's in version 1.0.14. It's in beta in my > eyes because I'm porting it over from standard JavaScript and the > additional jQuery functionality. I'm sure in the future this project > will advance much. And as far as having a demo, I will have one up > shortly. I honestly have had very limited time to work on this > project. Bare with me guys :). > > On Dec 18, 5:36 pm, Shawn <[EMAIL PROTECTED]> wrote: > > > Sounds like a good plugin, but may I offer a couple of suggestions? > > > 1. Post a demo of the plugin. I don't have time to download and setup > > all the plugins I might potentially want to use. A quick sample takes > > me seconds to make that evaluation, rather than 30+ minutes to go > > through a setup area. > > > 2. I don't mean to curb your enthusiasm, but I have a problem with 0.01 > > releases getting posted to the plugins page. As a developer looking for > > a solution, I'm looking for something that is at least mature enough to > > be considered stable. a 0.01 version is still beta (to me at least). I > > can't bash you tooo hard on this though - I have my own plugin posted on > > my site at a 0.01 version. But I wouldn't dream of posting this to > > plugins.jquery.com at this time. :) > > > I'm interested to see where your plugin goes. I can see a lot of > > potential for a spreadsheet like grid. > > > Shawn > > > Robert-CFL wrote: > > > I know there's not to much content, but let me know if you want to > > > help out with this plugin. it has GREAT possibilities. I know alot > > > of people have been looking for something like this. let me know what > > > you guys think. > > > > I'll work on documentation when i get time. > > > >http://plugins.jquery.com/project/Sheet
[jQuery] Re: My First jQuery Plugin..... jQuery.Sheet, a spreadsheet for jQuery
Actually, I thank you for the criticism. The reason that I went ahead and posted it was because it is (in reality) past a beta state in that it works and at TrimPath it's in version 1.0.14. It's in beta in my eyes because I'm porting it over from standard JavaScript and the additional jQuery functionality. I'm sure in the future this project will advance much. And as far as having a demo, I will have one up shortly. I honestly have had very limited time to work on this project. Bare with me guys :). On Dec 18, 5:36 pm, Shawn <[EMAIL PROTECTED]> wrote: > Sounds like a good plugin, but may I offer a couple of suggestions? > > 1. Post a demo of the plugin. I don't have time to download and setup > all the plugins I might potentially want to use. A quick sample takes > me seconds to make that evaluation, rather than 30+ minutes to go > through a setup area. > > 2. I don't mean to curb your enthusiasm, but I have a problem with 0.01 > releases getting posted to the plugins page. As a developer looking for > a solution, I'm looking for something that is at least mature enough to > be considered stable. a 0.01 version is still beta (to me at least). I > can't bash you tooo hard on this though - I have my own plugin posted on > my site at a 0.01 version. But I wouldn't dream of posting this to > plugins.jquery.com at this time. :) > > I'm interested to see where your plugin goes. I can see a lot of > potential for a spreadsheet like grid. > > Shawn > > Robert-CFL wrote: > > I know there's not to much content, but let me know if you want to > > help out with this plugin. it has GREAT possibilities. I know alot > > of people have been looking for something like this. let me know what > > you guys think. > > > I'll work on documentation when i get time. > > >http://plugins.jquery.com/project/Sheet
[jQuery] Re: My First jQuery Plugin..... jQuery.Sheet, a spreadsheet for jQuery
Sounds like a good plugin, but may I offer a couple of suggestions? 1. Post a demo of the plugin. I don't have time to download and setup all the plugins I might potentially want to use. A quick sample takes me seconds to make that evaluation, rather than 30+ minutes to go through a setup area. 2. I don't mean to curb your enthusiasm, but I have a problem with 0.01 releases getting posted to the plugins page. As a developer looking for a solution, I'm looking for something that is at least mature enough to be considered stable. a 0.01 version is still beta (to me at least). I can't bash you tooo hard on this though - I have my own plugin posted on my site at a 0.01 version. But I wouldn't dream of posting this to plugins.jquery.com at this time. :) I'm interested to see where your plugin goes. I can see a lot of potential for a spreadsheet like grid. Shawn Robert-CFL wrote: > I know there's not to much content, but let me know if you want to > help out with this plugin. it has GREAT possibilities. I know alot > of people have been looking for something like this. let me know what > you guys think. > > I'll work on documentation when i get time. > > > http://plugins.jquery.com/project/Sheet
[jQuery] Re: My First jQuery Plugin..... jQuery.Sheet, a spreadsheet for jQuery
The demo page is not loading any jquery. if this is the url http://jqueryplugins.weebly.com/jquerysheet-in-action.html - S On 18/12/2007, Robert-CFL <[EMAIL PROTECTED]> wrote: > > > I know there's not to much content, but let me know if you want to > help out with this plugin. it has GREAT possibilities. I know alot > of people have been looking for something like this. let me know what > you guys think. > > I'll work on documentation when i get time. > > > http://plugins.jquery.com/project/Sheet >