[jQuery] Re: Port Prototype Code to jQuery?

2009-09-01 Thread Josh Powell
can you send the html too?

[jQuery] Re: event-binding to dynamically created elements... (JSP vs JS problem......)

2009-08-30 Thread Josh Powell
sorry .up() is prototype... should be .parent() instead. On Aug 30, 1:20 pm, Josh Powell wrote: > kali - here is a way to accomplish the same thing in less code, and > lets you call the images anything you want instead of having to use > numbers.  This is untested so there ma

[jQuery] Re: event-binding to dynamically created elements... (JSP vs JS problem......)

2009-08-30 Thread Josh Powell
kali - here is a way to accomplish the same thing in less code, and lets you call the images anything you want instead of having to use numbers. This is untested so there may be some slight errors, but the logic should be sound: $(function() { var imageArray = ['foo', 'bar', 'baz'];

[jQuery] Re: event-binding to dynamically created elements... (JSP vs JS problem......)

2009-08-30 Thread Josh Powell
Even simpler: $('img.thumb').click(function () { $(this).toggleClass('dim'); });

[jQuery] Re: event-binding to dynamically created elements... (JSP vs JS problem......)

2009-08-30 Thread Josh Powell
op using id's when you have an unknown or changing number of items you are iterating through to do things. IDs should only be used for unique items. When you have a list of similiar items doing the same thing, give them all the same class or custom attribute and let jQuery do the iterating for

[jQuery] Re: empty() is very slow

2009-08-28 Thread Josh Powell
Change the onclick event handler into a jQuery .live() event and you'll be fine for sure. On Aug 26, 1:57 pm, oleOhle wrote: > OK, thanks everybody! I think I understand. > > Actually my second attempt could easily be rewritten to match exactly > what jQuery does. It really boils down to the rem

[jQuery] Re: empty() is very slow

2009-08-26 Thread Josh Powell
.empty and .html looks in every node that it removes/replaces and checks for and removes event bindings in order to prevent memory leaks. If you know you do not have bound events, first use plain old javascript to set element.innerHTML = ''; and then remove/replace the element using .empty()/.htm

[jQuery] Re: Live() event doesnot refresh the class of the event which was changed dynamically.

2009-07-05 Thread Josh Powell
comparison against the selector every time the mouse moves over an element on the page. This can cause some dramatic slowdowns, especially if you are using multiple live events of these types. It's often better to use regular events for mouseover, mouseout, and mousemove. Josh Powell On Jul 5, 9:

[jQuery] Re: Array to JSON?

2009-06-22 Thread Josh Powell
That's okay, javascript doesn't have associative arrays, only arrays with object properties. On Jun 22, 2:45 pm, Ricardo wrote: > before someone complains: that function won't handle arrays (only > objects) > > On Jun 22, 6:39 pm, Ricardo wrote: > > > Usually you'll send out parameters in query

[jQuery] Re: Using Zend IDE with jquery

2009-06-12 Thread Josh Powell
zend with eclipse has some plugins. I don't use them though, so I'm not sure where to get them. On Jun 12, 2:13 pm, Arun wrote: > Hi, > Has anyone ever tried using the zend ide with jquery? Any comments on > this would be appreciated. > > Arun

[jQuery] Re: Any way to make an anonymous function die?

2009-06-03 Thread Josh Powell
I think you are looking to namespace the event. $(selector).live('click.ns'); $(selector).die('click.ns'); The die() will only remove the click that occurs with that namespace and leave other click events alone. On Jun 2, 12:07 pm, Laker Netman wrote: > On Jun 2, 1:59 pm, Laker Netman wrote:

[jQuery] Re: performance of html(val)

2009-05-27 Thread Josh Powell
It's generally a good idea to post example code so we can see what you are doing. That said, this article I wrote will probably help you: http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly Josh Powell On May 26, 8:29 pm, jonathan wrote: > I am constructing

[jQuery] Re: What happen with jQuery? Is it slow?

2009-05-23 Thread Josh Powell
re trying to test the method, then the method should be pulled out and tested individually, if you are trying to test the pattern then you should test the most efficient patterns for each method. On May 22, 10:35 pm, RobG wrote: > On May 23, 6:48 am, Josh Powell wrote: > [...] > > &

[jQuery] Re: What happen with jQuery? Is it slow?

2009-05-22 Thread Josh Powell
One of the areas of the comparison where jQuery fares the worst is "destroy." jQuery checks every element it is removing to see if there are events bound to it and removes those events because they can cause memory leaks. None of the other libraries do this. I do wish that jQuery provided a met

[jQuery] Re: jQuery, MooTools, and Prototype - A Comparison

2009-05-21 Thread Josh Powell
What do you want to use the library for? Selecting DOM Elements DOM Manipulation Simplifying Events Simplifying Ajax Mimicking classical inheritance Extending native objects with 'missing' capabilities Cool Widgets >From what I can tell, these are the main areas of focus of all the major javascr

[jQuery] Re: Best book to learn jQuery?

2009-05-19 Thread Josh Powell
The Definitive Guide is a great reference book, and a terrible book to learn javascript from. Javascript: The Good Parts is a must read to understand the prototypical nature of javascript, learn about jslint, and understand == vs === I can't speak to Learning Javascript On May 19, 6:15 pm, d3a1

[jQuery] Re: question about getJSON, objects and/or scope - confused

2009-05-19 Thread Josh Powell
ment is finished loading, at that point the document.write() will already have executed and thisStory.title won't exist yet. Josh Powell On May 19, 2:22 pm, illovich wrote: > Hi, I'm working on a page where graphics/content get loaded via server > side stuff and decided to try to use JSON t

[jQuery] Re: Best book to learn jQuery?

2009-05-18 Thread Josh Powell
r but there is lots of good stuff in there. You can also start readign at: http://javascript.crockford.com/ Josh Powell On May 18, 12:37 pm, alex wrote: > Ah. I'm sure this sounds dunce-y because 'jQuery does it for me', but > is a solid grounding in Javascript ne

[jQuery] Re: I'll Donate $20USD to Jquery if you can teach me how to do this

2009-05-18 Thread Josh Powell
If you aren't forced to use XML, look at trying JSON instead. It is a MUCH friendlier format for passing information around. On May 17, 11:09 pm, KrushRadio - Doc wrote: > Paypal Transaction ID: 8PY233604R986225R :D > > Thanks for your help. > > Actually, there were 2 parts that I didn't get..

[jQuery] Re: The jQuery Object, Namespaces, and Program Modules -- Connecting the Dots Between jQuery and Javascript

2009-05-05 Thread Josh Powell
Try this: http://www.learningjquery.com/category/levels/beginner?order=ascending On May 5, 9:08 am, kiusau wrote: > On May 5, 8:24 am, Rey Bango wrote: > > > Great advice Matt. > > But, no source! > > Roddy

[jQuery] Re: Jquery and Other Libraries Error

2009-04-26 Thread Josh Powell
your code. Josh Powell On Apr 26, 7:42 am, Sparky12 wrote: > Problem is that I read > thehttp://docs.jquery.com/Using_jQuery_with_Other_Libraries > - and i use "jQuery" now ? So not sure why its occurring? > > P.S - About code - i dont even use my own code. I just use thi

[jQuery] Re: Alternate $.load

2009-04-23 Thread Josh Powell
It would be much easier to generate a json response instead of html and use .getJSON and then the DOM insertion functions to generate the html you need on the page. On Apr 23, 1:41 am, Colonel wrote: > This isn't entirely correct, and not quite what I had. For example I > have a lots of divs in

[jQuery] Re: jQuery Ajax Error in Firefox 3.0.8

2009-04-22 Thread Josh Powell
what does ajax.php return? at what stage is the error, beforesend, error, success, complete? Put in a console.log and see if it is executed in each of the states. Just a style suggest, but reverse your usage of quotes: $('#searchresult').html('  '); instead of $('#searchresult').html("  ");

[jQuery] Re: Any benefit to using event.preventDefault() over "return false" to cancel out an href click?

2009-04-20 Thread Josh Powell
It sounds like John is saying that e.preventDefault() will prevent the default event from occuring and e.stopPropogation() will prevent the event from bubbling up and return false will do both, so If you only want to stop the default but allow propogation or vice versa, then use the methods, oth

[jQuery] Re: jquery-1.2.6.min.js and mootools.v1.1.js not compatable

2009-04-20 Thread Josh Powell
http://docs.jquery.com/Core/jQuery.noConflict On Apr 20, 12:54 pm, amanj wrote: > Hi All, > i have a problem with web page, i have 2 js files for tow topic > jquery-1.2.6.min.js > mootools.v1.1.js > those file are not compatable togeher, please if have any thing or any > problem could you advic

[jQuery] Re: Questions about $.live, Live Query and performance

2009-04-19 Thread Josh Powell
Geoff - Selectors do make some difference, they always do, but the way I've heard that .live() works is to add an event handler on the document root and when events bubble up to it, doing some javascript mojo to detect what element that event happened on and seeing if it matches the selector. .li

[jQuery] Re: Append before closing tag

2009-04-19 Thread Josh Powell
Below is the call and where the code passed into the call would place the content. $('#aP').before(); $('#aP').prepend(); lorem ipsim dolor sit amet... $('#aP').append(); $('#aP').after(); On Apr 18, 11:49 pm, MauiMan2 wrote: > Does jQuery provide a way to append an element immediately before

[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Josh Powell
Thanks all, Josh On Apr 16, 12:06 pm, Kean wrote: > @Josh Powell > - string concatenation is plenty fast 99% of the time and a lot more > readable. > Yes string concatenation is more readable and 99% faster for normal > usage. But looping and concatenate a huge chunk in this pa

[jQuery] Re: Creating custom attributes in html

2009-04-16 Thread Josh Powell
@all - So far, the only reasons I've heard not to add custom attributes are 1) Dogma, 2) May cause quirks mode. In my mind, the benefits gained by using custom attributes: less code, simplicity, and clarity, far outweigh these two reasons not to do it. @Jack K - Thanks for the links :). I will

[jQuery] Re: Calling a function from a non-jQuery .JS file

2009-04-15 Thread Josh Powell
> ...what is wrong with just having:- > var todayEl = document.getElementById("today"); > todayEl.innerHTML = formatDate(new Date); document.ElementById has a bug in ie6 and ie7 that will return an element with a name attribute of the same value. Use $('#today') instead. todayEl.innerHTML = "so

[jQuery] Re: Creating custom attributes in html

2009-04-15 Thread Josh Powell
@all - thank you for your comments. What I've learned is 1) custom attributes are referred to as DOM Expandos, 2) they can cause IE to go into strict mode, 3) Developers often override the class or id of an element to store data instead of using a DOM Expando, and 4) There is a bug in jQuery hav

[jQuery] Re: Creating custom attributes in html

2009-04-14 Thread Josh Powell
I cannot use .data() as I do not have a node. Creating a node for every td creates impossibly excessive append time. One one page I shortened the time to append for 500 table rows from 29,000ms to 900ms. Good to know about the potential for triggering quirks mode though, thanks. Josh Powell

[jQuery] Re: Difference between .bind() and .click()

2009-04-06 Thread Josh Powell
.bind enables you to pass variables into the callback function via the e.data attribute in the event. $(document).bind('click', {'foo': 'bar'}, function(e) { console.log(e.data.foo); }); Can't do that with the .click shortcut. Josh Powell On Apr 6, 9:53 a

[jQuery] Re: Need to get value of table cell

2009-03-25 Thread Josh Powell
27; > td).each( function () { alert($(this).text()); // to get just the text alert($(this).html()); // to get the full html inside instead } ); Find more on selectors at: http://docs.jquery.com/Selectors and more on the .text() & .html() at: http://docs.jquery.com/

[jQuery] Re: getJSON() response into a table

2009-03-21 Thread Josh Powell
instead of obj['name'] use obj.name They both work, but the first makes it look like a hash when you are really using properties of an object. Cheers, Josh Powell

[jQuery] Re: How to call jQuery function inside a DOM

2009-03-21 Thread Josh Powell
While not what you were asking, remember that you can chain. var name = $("#label"); var nameInfo = $("#nameInfo"); name.blur(validateName).keyup(validateName); ... nameInfo.text("We want names with more than 3 letters!").addClass ("error"); Then: $('#addPhoneExt').click(tb_remove); sets an on

[jQuery] Re: jQuery and Prototype conflict

2009-03-20 Thread Josh Powell
In this: jQuery(document).ready(function($){ $("#example").autocomplete(options); }); this: function($) { }) is overwriting the $ for prototype. It should be: jQuery(document).ready(function(){ $("#example").autocomplete(options); }); without passing t

[jQuery] Re: Preventing link clicks before document.ready();

2009-03-20 Thread Josh Powell
You could also put the .click events inside a document.ready(). Then they can click away, but no results until the event handler is set after document.ready. On Mar 20, 12:30 pm, James wrote: > That's the default of how web browsers. You can work around it such as > by setting the display of th

[jQuery] Re: jQuery each problem

2009-03-15 Thread Josh Powell
ns nothing > > $(this).val() returns "on" no matter if you click on button Yes or > > button No > > I have been ckecking jquery doc the best I could and cannot find > > answer to my question: how to I know if user clicked on button Yes or > > button No > >

[jQuery] Re: jquery each help

2009-03-15 Thread Josh Powell
read up on the .animate() jQuery effect, this might be what you are looking for. http://docs.jquery.com/Effects/animate On Mar 15, 11:46 am, Tom Shafer wrote: > I have articles in a group of divs > >                         width="11" > height="211"/> >                         >            

[jQuery] Re: .getJSon

2009-03-14 Thread Josh Powell
is a perfectly valid way to code. On Mar 14, 2:10 pm, donb wrote: > Then I must be missing something: > > $("#placetoinsert").load("path/to/url"); > > would do the same thing, with the tableHTML constructed on the server > side. > > On Mar 14, 5:02 p

[jQuery] Re: Very New To JavaScript\JQuery - Mouseover and Mouseout Question

2009-03-14 Thread Josh Powell
The problem is this: $(".block a").mouseover(function(){ $(".block a").animate({ $('.block a') gets every instance of an a element with class block. So when you do the .animate on it, you are animating every element. Instead, you mean. $(".block a").mouseover(function(){ $(this).

[jQuery] Re: .getJSon

2009-03-14 Thread Josh Powell
Because it puts it in the javascript and lets you easily manipulate it with javascript. If you get html back from the server, it's more difficult to manipulate. $.getJson('path/to/url', function(data) { var tableHTML = ''; $.each(data.aaData, function() { tableHTML += '' + this

[jQuery] Re: find among same elements using name

2009-03-14 Thread Josh Powell
[name=row] On Mar 14, 10:58 am, Alain Roger wrote: > Hi, > > i have a table with checkboxes which allows user to select all row/records > or none. > they have all the same name : row > i would like to know if there is an easy way to find them in my table ? > i was thinking about something like

[jQuery] Re: jQuery each problem

2009-03-14 Thread Josh Powell
doc)  that you can use > > jQuery('.choix').click(function(e) { > > $(this).parent().parent().hide(); > > and it will go 2 levels up instead of one as described in you solution > > Thanks to great people like you Josh I am learning ( slowly) > > Many thanks &g

[jQuery] Re: Please help me SPEED UP my dev. MySQL => PHP => JSON => AJAX => jQueryUI

2009-03-14 Thread Josh Powell
No, JSON is the correct route. If you are using ajax to retrieve json, then you can pull the json into a javascript object immediately. If you are using PHP to generate pages, then you can print out the JSON object as a string directly into javascript and create javascript objects that way. jQu

[jQuery] Re: Using " " (or not!)

2009-03-14 Thread Josh Powell
$("#msgUnits").text( ); will definitely not work.   is not the name of a javascript object. On Mar 13, 9:46 pm, Swatchdog wrote: > This does not work: > > $("#msgUnits").text( ); > > nor does this... > > $("#msgUnits").text(' '); > > I guess   is html only? > > Clues, anyone?

[jQuery] Re: jQuery each problem

2009-03-14 Thread Josh Powell
.. it will hide the related div with id="quest1" or > quest 2... > Any ideas > Thanks for help > Jean from France > > On 14 mar, 00:57, Josh Powell wrote: > > > What this is doing: > > > jQuery('.choix1').click(function(){ > >   jQuery

[jQuery] Re: jQuery each problem

2009-03-13 Thread Josh Powell
What this is doing: jQuery('.choix1').click(function(){ jQuery('#quest1').hide(); }); is looping through every element on the page with a class of 'choix1', so you could either change all of the elements you want to loop though classes to choix and then do jQuery('.choix').click(function(){

[jQuery] Re: Invalid Argument in IE7/8

2009-03-13 Thread Josh Powell
Where does this error come from? [cycle] terminating; zero elements found by selector You can see it when the page loads on the firebug console, but it doesn't give a file name or line number. it may be that since you aren't getting any elements back, IE is messing up because you are trying to

[jQuery] Re: triggering events with selected

2009-03-13 Thread Josh Powell
1 2 3 4 5 content content content content content $('.numberPages').change(function() { $('p.foo').hide().eq($(this).find(':selected').text()-1).show(); });

[jQuery] Re: $(byName) <> $(byClass) in 1.3.2

2009-03-12 Thread Josh Powell
You can still use name, just change your selector to $('[name=div1]') Also, when writing out html in string, put them between single quotes and the html in double quotes so you can do this: var htmlText = 'Hola!!'; instead of var htmlText = 'Hola!!'; Josh Pow

[jQuery] Re: Very simple question...

2009-03-11 Thread Josh Powell
@7times9 I'm not sure what eq() stands for, come to think of it, but I always read it in my heads as 'equals' as in the index equals 2. > On Thu, Mar 12, 2009 at 10:04 AM, 7times9 <7tim...@googlemail.com> wrote: > > > ...what does eq as in .eq(2) stand for? > > > It helps me to read jQuery in my

[jQuery] Re: Order Items. Please help me. Thank You.

2009-03-11 Thread Josh Powell
@mkmanning > An even more important performance gain can be had by > not doing string concatenation (I put a caveat about this in the code > comment's also), but build an array of your html and then join the > array; it's siginficantly faster. Funny that you mention this. In current browser vers

[jQuery] Re: Get Textbox-value and write to table-cell ()

2009-03-11 Thread Josh Powell
;).slice(3) + ]').val($ (this).val()); }); I personally find this kind of string munging difficult to read and maintain. Could just be personal preference though. Good luck. Josh Powell On Mar 10, 10:39 pm, Eric Gun wrote: > @mkmanning: Well done!! Your script works well. Thanks, and gre

[jQuery] Re: Get Textbox-value and write to table-cell ()

2009-03-07 Thread Josh Powell
6 of one... half dozen of another... On Mar 7, 12:04 pm, brian wrote: > On Sat, Mar 7, 2009 at 2:16 PM, Josh Powell wrote: > > > Why do you have the [] characters in the name of the elements?  That > > might screw up selectors. > > PHP, likely. But there's n

[jQuery] Re: Get Textbox-value and write to table-cell ()

2009-03-07 Thread Josh Powell
Why do you have the [] characters in the name of the elements? That might screw up selectors. Another options is to give the dealAmount inputs a new attribute with a value of an incrementing numbers, foo="0" say. As long as the post amounts are in the same order you could: $('[name=dealAmount'

[jQuery] Re: display children using jQuery

2009-03-07 Thread Josh Powell
Long answer: Check out the section on Traversing in the jquery documentation on the site. Lots of good examples and documentation on there. Short answer: console.log($(element).children())); On Mar 7, 1:33 am, Alain Roger wrote: > Hi, > > i need to debug jQuery code and i would like to know

[jQuery] Re: can't get started

2009-03-05 Thread Josh Powell
Did you mean to: instead of On Mar 5, 3:37 pm, dawnerd wrote: > Can you please post the html you were using? > > On Mar 5, 2:32 pm, Dr G wrote: > > > Hello, > > > I've downloaded both the compressed & uncompressed versions and tried > > both the initial example from the jquery site (http:

[jQuery] Re: How to create dom on the fly using jQuery????

2009-03-04 Thread Josh Powell
Simple answer: DOM nodes are created by just writing the html in side of the jQuery $('#divName').append(''); is equivalent to divResult = document.getElementById("divName"); table = document.createElement("table"); tr = document.createElement("tr"); td = document.createElement("td"); tr.appen

[jQuery] Re: Optimize large DOM inserts

2009-03-02 Thread Josh Powell
Hey guys, This thread inspired me to write a blog article http://www.learningjquery.com/2009/03/43439-reasons-to-use-append-correctly I did some testing of the += and array.join methods of long string concatenation. Interesting stuff! It turns out that += and array.join are browser dependent

[jQuery] Re: $.getJSON

2009-03-02 Thread Josh Powell
Using console.log and firebug will show you what everything is. console.log(data); $.each(data.records, function(i,item){ console.log(i); console.log(item); console.log(this); }); On Mar 2, 1:54 am, Alain Roger wrote: > On Mon, Mar 2, 2009 at 10:52 AM, Matt Quackenbush wrote: > > > > >

[jQuery] Re: I can't figure out how to implement JQuery into my website

2009-03-01 Thread Josh Powell
It's just a javascript file, put it wherever you put your javascript files. On Mar 1, 12:20 pm, Warfang wrote: > What code do I need to put in my HTML header? I have already > downloaded the JQuery code from JQuery's homepage to my computer, but > where exactly do I put that? I'm using Webs.com

[jQuery] Re: Help please with toggling a class

2009-02-27 Thread Josh Powell
oh, very nice. I wasn't aware of toggleClass. On Feb 27, 6:51 pm, Karl Swedberg wrote: > Hi Zac, > > You just need to add one line -- $(this).toggleClass('yourClass'); --   > where "yourClass" is the class you want to toggle on and off. > > You should also add return false after that line so th

[jQuery] Re: alternate color row starting from a point

2009-02-27 Thread Josh Powell
hmmm, tough one, it was fun. $(function() { var color = ''; $('#everyother tr').each(function() { if( $(this).hasClass('className') ) { color = 'red'; } else if (color === 'red') { $(this).css({'background-color': 'red'}); color = '';

[jQuery] Re: Help please with toggling a class

2009-02-27 Thread Josh Powell
Without really understanding what your fadeToggle plugin is doing, this will toggle adding and removing a class: $(function() { $('a.aboutlink').toggle( function () { $(this).addClass('aboutBox');

[jQuery] Re: Multiple inclusions of jquery possible?!?

2009-02-27 Thread Josh Powell
http://groups.google.com/group/jquery-dev/browse_thread/thread/3efd1066b535234f On Feb 27, 3:19 pm, ml1 wrote: > Hi folks: > > We use jquery extensively in an application that suddenly needs to > make use of an online ecommerce system that also happens to use > jquery. > > This is causing thin