From: Feed
Thanks Ian, it seem to be working perfectly. I just have one more
question: isn't there a big performance impact using this
piece of code? It looks like the page it taking a while do
load, but I guess you have to choose between the time the
page takes to load and the time
From: Ian Struble
Just out of curiosity is there a way to break out while
iterating with .each()? Again building on the previous
example (Mike's #2 this time):
$(function() {
$('tr').each( function() {
var allEmpty = true;
$('td', this).each(funcion() {
From: [EMAIL PROTECTED]
How can I use JQuery to discover if a particular ID occurs
twice in my page? I can't use View Source' because the DOM
is changing as the user interacts with the page.
Reading between the lines here, it sounds like you don't have the View
Source Chart plugin for
From: SamCKayak
In ASP, I am building a JSON object and escape the data using
Server.URLEncode(strParmChoices)
It seems this encodes blanks as a plus sign +.
Back in JavaScript, it looks like unescape(+) leaves the
plus as a plus. I've band-aided the problem using
In ASP, I am building a JSON object and escape the data using
Server.URLEncode(strParmChoices)
It seems this encodes blanks as a plus sign +.
Back in JavaScript, it looks like unescape(+) leaves the
plus as a plus. I've band-aided the problem using...
Use decodeURI()
Whoa there. Synchronous AJAX calls? You're locking up the browser when you
do that. What if your server is slow to respond?
If it's just a coding convenience, don't do it!
-Mike
_
From: Jimmy Glass
By default, I have set all AJAX requests to syncronous as I like to have the
I'm pretty new to jQuery and JS in general. I managed to
build something. I learned a lot! THX jQuery guys. When you
look into my code, could it be shorter, smarter, sharper?
especially this part:
[code]
$(document).ready(function(){
On Thursday, May 24, 2007 12:25 PM Chris W. Parker said:
Whoops. I guess I forgot to change the address.
Too late! We all want to hear the answers to those train questions now.
-Mike
Very nice!
A couple of suggestions...
1) Get in the habit of using var on all your variable assignments, so you
don't create global variables accidentally.
2) Consider using one of the several DOM creator plugins. You can replace
code like this:
figureFrameInner =
From: Diego A.
In IE (6 and 7) the compressed version of jQuery is adding
the following text to the document:
id=__ie_init defer=true src=//:
I know it's related to the following code (from line 1493):
// Only works if you document.write() it
Your json.js file is not valid JSON. It is executable JavaScript code, but
any actual JSON parser will reject it.
JSON is a limited subset of JavaScript and cannot contain function
definitions:
http://json.org/
-Mike
From: [EMAIL PROTECTED]
Has nothing to do with jQuery directly, but
Angelo, can you post a link to a test page? Without seeing the problem in
action, we would all be just guessing.
From: Angelo Zanetti
I have been having trouble with integrating JS into existing website.
The particular files that we are trying to include the Jquery
into the JS that exists
From: Michael E. Carluen
http://dojotoolkit.org/developer
Yes, the list continues to grow. I find it a little amusing
to see that even the Dojo site uses jQuery and its plugins.
That's a good find! :-)
Dojo converted their site to Drupal, so of course it uses jQuery just like
any
getJSON won't work, but my JSON plugin will. It's designed for this kind of
cross-domain use:
http://mg.to/2006/01/25/json-for-jquery
-Mike
_
From:
it won't work!
getJSON uses ajax... ajax can't go to another site.
On 6/20/07, LVCHEN [EMAIL PROTECTED] mailto:[EMAIL
.ready isn't really an event, it's all special case code.
Instead of trying to unbind a function, you could set a flag and test it in
the function in question.
But what it is you're really trying to do? I don't see exactly what the goal
is here.
-Mike
_
From:
Rey, no offense, bud, but synchronous ajax is a last resort. It freezes the
browser while the ajax data is loaded. You don't want to use it unless
you're certain that it's necessary - and that is rare.
Andy, the real question is what you want to do. Scope is not a problem: You
can easily assign
John, the problem is probably that browsers will normally do only two (or
some small number of) simultaneous downloads per domain. When you append the
HTML for all your thumbnails and then later ask for a full image, it gets
queued up behind all those thumbnail downloads.
Is there any way you
You are definitely on the right track, Gordon.
Here's the code you need:
// Add a stylesheet with the given CSS styles (a text string)
// and return a reference to it
function addStyleSheet( css ) {
var sheet = document.createElement( 'style' );
sheet.type =
I left out one line of code in my previous reply. Add this line before the
two function definitions:
var head = document.getElementsByTagName('head')[0];
Oops! :-)
-Mike
From: Michael Geary
You are definitely on the right track, Gordon.
Here's the code you need:
// Add
I think we are talking about the same thing, but coming at it from different
angles. The code I posted is a building block you could use to write your
own animation function. It's not the jQuery feature you want, just a start
on it. :-)
I meant to ask: how many elements are you animating
As Rob suggested, explore what you can do with the selectors available in
jQuery. But if those don't do the trick, keep in mind that the jQuery result
object is an array. If you want to do something unusual with it that isn't
provided by the jQuery selectors, you can access the array elements
You could use event bubbling. Set a click event handler on a parent element
that contains all of your clickable questions. In that click handler, check
this to see if it actually is one of the clickable questions and take your
action then.
-Mike
From: [EMAIL PROTECTED]
What I'm trying to
Felix, not to worry, there's nothing wrong at all with using .length - and
it is obviously faster than a function call.
In the earliest versions of jQuery, the jQuery object was not an array, but
had a private array object that you accessed using .get(n) and .size(). The
only reason those
There's no reason at all to stick with .get(n) and .size()
now that the array-like jQuery object allows the
simpler and more efficient [n] and .length.
I disagree. Whenever you need to sort the elements in an
ul or something then you'll have to use the Array.sort()
function, so you
From: Terry B
lets say i try and add
tabletrtdSome Info/tr/td/table
it ends up being something like
TABLETBODYTRTDSome Info/TD/TR/TBODY/TABLE
What problem do you see there? It looks perfectly correct to me. TBODY is a
required element which the browser is kind enough to insert
From: Terry B
lets say i try and add
tabletrtdSome Info/tr/td/table
it ends up being something like
TABLETBODYTRTDSome Info/TD/TR/TBODY/TABLE
From: Michael Geary
What problem do you see there? It looks perfectly correct to
me. TBODY is a required element which
Just guessing (i didn't see the original post), but there's such a
framework on Douglas Crockford's site:
http://www.crockford.com/javascript/inheritance.html
It's pretty simple to use, but the example code on that page is
unfortunately out of order (by that i mean not organized
well,
I don't see it happening here. This is the URL list I got using IE7 and
Fiddler2:
http://alpha.z3c.org/
http://alpha.z3c.org/@@/xmlhttp.js
http://alpha.z3c.org/@@/json.js
http://alpha.z3c.org/@@/jquery.pack.js
http://alpha.z3c.org/@@/jsonform.validate.js
http://alpha.z3c.org/@@/interface.js
Tane, load your page in Firefox with Firebug enabled. Open the Firebug pane
and click Script, then turn on Options/Break on All Errors. Now do your
address lookup.
Firebug will stop on your line with the error. Look at what is displayed in
the Watch window. Observe that this is the Window
From: Klaus Hartl
PS: Someone posted a guide to posting to mailing lists and
increasing the chances of getting help, but unfortunately I
cannot find it anymore.
Does anybody remember that?
That would be the (in)famous How to ask questions the smart way by Eric
Raymond:
From: SteelSoftware
I'm having trouble with a bit of jQuery. It seems that if I include
the following lines into my code, the page follows the link that i'm
clicking instead of staying on the same page:
var $ref = $(#calendar .#navleft).attr(href).text();
$(#calendar .nav).attr(href,
Great, I'm glad you got it working, Steve.
Check out Dan's followup comments for some good ideas on optimizing your
code.
I'd add one more thing to that. I suggest using the $ prefix on variable
names only when you are storing a jQuery object in that variable.
For example:
var $this =
From: Michael Geary
var $navleft = $(#navleft);
$navleft.attr( href, $navleft.attr(href).slice(0,-1) + '0' );
Or even this (which is probably the way I'd code it myself):
var navleft = $(#navleft)[0];
navleft.href = navleft.href.slice(0,-1) + '0';
I may have been
From: John Resig
Added to the FAQ:
http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_compress_by_code.
3F
I tink you have a code in da doze. Dry sub Codtac:
http://docs.jquery.com/Frequently_Asked_Questions#How_do_I_compress_my_code.
3F
-Mike
Sounds interesting, Aaron, thanks for the pointer.
Two questions:
How is the unpacking speed? I don't care how long it takes to pack the code
(within reason), but unpacking speed is very important, especially on slow
machines like an iPhone/Nokia/Windows Mobile phone. I saw a test report that
Nifty idea, but this will only work within a single domain, right?
From: Jean-Francois Hovinne
jFeed is a new jQuery plugin which parses RSS/ATOM feeds.
It uses jQuery's built-in AJAX functions to get the XML and
basic selectors to parse it.
More info on my blog:
Ah, of course. Server proxy. I should have thought of that. Very nice - will
take a look at it!
From: Jean-Francois Hovinne
Yes, though you can use a server-side proxy to load external feeds.
BTW, a basic one is provided in the archive for testing purposes.
On 15 juil, 23:25, Michael Geary
My understanding is we put script tags in the head so as to not
clutter up the body DOM. I don't think it has anything to do with
ready(), and I'm pretty sure ready() doesn't require
script tags to be in the head...
Yes, but if you put the scripts at the end of the body you
Very cool idea. Anything to get rid of confirmation dialogs!
I see one problem: Many people habitually double-click everything - links,
buttons, you name it. If you double-click the button, the second click ends
up confirming it.
You could avoid this by disabling the button for a second with a
Now that i think about it, i'm constantly saying to my g/f, don't
DOUBLE-click those links! That causes two hits on the server! as if
she might someday magically understand what i mean by that. :/
I'll also confirm that my finding the majority of
non-hardcore users tend to double-click.
There actually is a similar problem that Windows apps can run
into if they close dialogs in the wong way. But I knew we
weren't doing that, and we couldn't repro the bug at all.
Proofread, Geary, proofread. Obviously wrong, especially after that second
glass of wine. :-)
And Resig says
When I was working at Adobe several years ago, we had a bug
report that none of us could reproduce or figure out.
The bug said that an unrelated window from another application
would pop to the front when a dialog in our app was closed.
There actually is a similar problem that
Mitch?!? Holy cow, it's good to see your name here.
Listen up, kids. The Waite Group published some of the most important books
of the microcomputer / personal computer revolution. Check the book list at
www.mitchwaite.com to see what I'm talking about. If you haven't heard of
some of these
Listen up, kids. The Waite Group published some of the most
important books of the microcomputer / personal computer
revolution. Check the book list at www.mitchwaite.com to
see what I'm talking about. If you haven't heard of some of
these books, rest assured that your elders have. :-)
From: Dan G. Switzer, II
What is this glossy plug-in your using?
I have a feeling that plug-in may be changing your images
from normal img / HTML tags to something embedded in a
canvas / tag or to SVG.
If that's the case, then it's definitely going to affect
jQuery--because the
From: juliandormon
Is it possible to write javascript dynamically so new
functions are created with the new parameters once the user
makes a change? These functions need to be added to the head
of my page because they get called after other functions. In
other words, the new functions
Rob, I think you left out the return statement that you meant to put in. :-)
(Outstanding explanation, BTW!)
For clarity, it could be:
jQuery.fn.toggleVis = function() {
this.each(function() {
if (this.style.visibility == 'hidden') {
this.style.visibility =
From: Michael Geary
The use of this inside an each loop is one of the two
major design errors in jQuery (the other being the event
system, which I'll get to another day).
Just to avoid any possible misunderstanding, I think everyone knows I
consider jQuery to be a brilliant piece of work
From: weepy
$s = function(s) {
p = s.replace(/#{/g, ' + eval().replace(/}/g, ) + ')
p = ' + p + '
return eval(p)
}
a=Jonah
b=30
$s(#{a} is #{b} years old)
== Jonah is 30 years old
From: Michael Geary
Sorry to be a party pooper, but what
Actually, Jay, the JavaScript is required. The CSS uses a hover class
which the JavaScript code applies to the element. hover has no intrinsic
meaning here; they could have called it reveal and it would work the same,
as long as the JavaScript code uses the same classname.
You're probably
It means whatever the server wants it to mean. It's just passed to the
server as part of the URL. In this particular case it looks like it requests
a specific version of the file, much like the way you can request a specific
version of the Google Maps API:
Andy, here are a few debugging tips...
1) Post a link to a test page instead of including a code snippet in a
message.
2) Where do you define the checkemail() function?
3) Use uncompressed copies of jQuery and Interface for debugging.
4) Load your page with Firebug enabled and the Break on
From: gecko68
Am I missing something regarding cross browser compatibility?
When I try to read parseInt($(#tagCloudData).css('width'))
I get NaN in IE, yet Firefox gives me the correct value.
The width is NOT set in the style sheet or in the style tag,
as it is variable. I want to
From: Jay Salvat
Sorry for the useless answer :)
Not useless at all! If anyone tried the code from my message, they would
have been disappointed. You caught the bit of CSS that I'd missed - thanks!
-Mike
I wonder what will happen if xray.js finishes loading before
jquery-latest.pack.js? :-)
The author should combine the two scripts into one file...
-Mike
From: Tobias Parent
For those who don't know how I found that it's a jQuery app,
I just right-clicked on the bookmarklet (after I'd
Hi Juan,
You probably shouldn't be making direct calls to a $.fn.methodName()
function.
I'm not sure what it is you want to accomplish, but perhaps a good example
would be the each function. There is a $.fn.each which is called when you
use $('.foo').each(). And there is a separate $.each that
I...cannot figure how what the heck === is.
I see that Jake answered your question, but just for next time...
You may have tried a Google search for javascript === and been
disappointed to find it returned no useful results (because Google seems to
ignore the === in the search).
The key thing
Wow, that *is* funny. I must confess that I didn't actually look at the
search results!
_
From: Ganeshji Marwaha
funny, both w3schools and javascriotkit (top 2 results for the query
javascript+operators) doesnt seem to have an explanation for !==. ;-)
On 8/1/07, Michael Geary [EMAIL
That's an interesting find, Rob, thanks. But watch out. We're looking at the
ECMAScript standard, not running code. An actual implementation could have
different performance for the two operators and still conform to the spec.
It does seem unlikely that anyone would code == to be slower than ===
From: Terry B
I have a bunch of events and I loop through them. I would
like to create a double-click effect so that I call function
eventDoubleClick but I want that event to pass its index value, as
such:
for (i=0, iarrayLength; i++)
{
$t(#event_ + i).dblclick(function ()
Frank, is the missing close brace a typo in the post, or is it missing in
your code too?
(Thanks to Komodo [1] for marking the syntax error with a squiggly red
underline.)
Also, what is $(this) == click supposed to do? That creates a jQuery
object and compares it with a string, which will
I just found the jQuery group and joined. I absolutely jQuery
after discovering the Thickbox. I need some help with this
task. I have an asp.net page for uploading photos. I want to
show a preview of the image once i have browsed for and
selected the image using the file input. How can
From: Alex Ezell
This is not possible because the image will not yet be on your server.
The browser will have no access to display an image local to
the user's machine within a web page.
Silly me, you are right. I was thinking you could use the file: URL in the
IMG tag, but that won't
Do you *generate* the HTML dynamically, or is it a static file?
If you generate it dynamically on your server, you can wrap the script
inside a function whose name comes from the query string. Then in
JavaScript, each time you start an ajax download, generate a unique function
name and pass that
http://www.scrollovers.com/
From: Klaus Hartl
Nice effect!
But hey, creating a new domain and on top calling it A new
way of linking is a little over the top I think ;-)
If all the links on a page would constantly behave like that
I'd go crazy - man, that would be annoying...
There are several different jQuery contexts, and this means something
different in each.
In a plugin method - jQuery.fn.foobar() - this is a jQuery object that was
constructed and returned by a $() or jQuery() call.
Inside an each() callback, this is the DOM element or object for the
current
Hey Pops,
I'm just going to address a couple of your questions for now - we can come
back to the detailed code later after it's more clear what you want to do.
First, let's call it jQuery, not JQUERY, so no one thinks you're shouting.
:-)
About catering specifically to jQuery, it's unlikely
From: Pops
I think, and this is more of a question, I think I need to
first create a new WCX that creates XML or JSON output only
to begin to take advantage of JQUERY. Then second, I need to
bind if that is the proper JQUERY term, the JSON fields
with a Table columns.
- Create a
From: Klaus Hartl
Yeah! I like how it is build on top of my basic cookie plugin
instead of rebuilding stuff...
Another example how well the plugin architecture works out.
...except that there's no plugin architecture at work here. :-)
These three plugins don't really need jQuery at
Pops, thanks for the additional information.
Before getting into too many details, let me check again: is this for your
own company's website, or are you building something that other people will
use on their websites to incorporate some of your data?
That will help clarify which approach to
Um. Guys. What was the very first jQuery plugin? :-) [1]
It's true, AJAX (XMLHttpRequest) won't work across domains, but JSONP with
the dynamic script tag works fine (except for a few versions of Safari like
2.0.0 - which should be pretty rare).
Eric, I saw your comment on my blog post (below)
Hi Eric,
As John pointed out, you can't use $.getJSON() across domains, because it
uses XMLHttpRequest which is subject to the same-domain policy.
I saw that you'd also tried to use my JSON plugin, which does handle
cross-domain requests because it uses a dynamic script tag instead of
Hi Pops,
It's possible to make cross-domain AJAX work if your
customer runs a proxy on their server, but not if you
want a pure client-side solution.
cross-domain is a possible requirement, and it is expected
the server will centralize such secured managed request.
Help me out here,
I'm not a big Spry fan because it's completely obtrusive to
the page. If you don't have JS enabled, then it completely
fails for you. That's why I'm not a huge fan of the
embedded HTML binding.
Curious, I might have misunderstood, but this is the 2nd time
some has made a reference to
From: Eridius
options =
{
var1: 'one',
var2: 'two'
}
Is there a way to loop throught this object like I can
do with .each?
You can *use* $.each:
$.each( options, function( key, val ) {
console.debug( key, val );
});
But beware! If your object happens to have a
Script tags aren't the only problem with html-who.wcx. It's full of
document.writeln() calls. If you load this file with XMLHttpRequest after
the page is loaded, it's far too late to call document.write[ln](). The
document has already been closed. If it works at all, the first
document.writeln
For example:
JSON: { test:value }
JSONP: myCallback({ test:value })
As you can see, the JSON part is the same, but putting it inside a
function call makes the whole thing executable code that will run
automatically when the script is loaded - assuming of
course that you have
From: WebolizeR
I implement the jQuery Validation plugin(http://bassistance.de/jquery-
plugins/jquery-plugin-validation/) to my order form which you
can see in
http://nexus.di-tasarim.com/index.php?option=com_nexusact=gallerytask=orde
rid=32
it works great in Firefox but I cannot
You are getting the head tag correctly (heads is an array with one element),
but the code probably ends up trying to set the innerHTML of a DIV in the
current document (not the iframe) in order to convert the link HTML to DOM
elements. If that conversion works, the LINK element belongs to the
Are you *sure* you want to do this?
It locks up the browser completely - and all other browser windows in many
browsers - until the ajax call returns.
If it's just a matter of coding convenience, balance that against the
inconvenience it will cause your visitors if the site is slow to respond.
From: pd
I've been hacking with jQuery on and off lately and I've now
hit the annoying problem of not being able to access simple
DOM 0 properties unless, apparently, using either of the
following syntaxes:
$('#foo')[0]
$('#foo').get(0)
pd, just to help clarify... The $()
From: Erik Beeson
The [n] syntax is just a shortcut for
.get(n):http://docs.jquery.com/Core#get.28_num_.29
From: Gordon
I would imagine that the [] syntax would be a bit faster than the
get() syntax, on the grounds that the former is simply
addressing an array, whereas the latter
One of the nice things about JavaScript is that it can be so easy to write a
general function for something like this.
To make a version of setInterval that also calls the function immediately,
all you need is:
function nowInterval( fn, time ) {
fn();
return setInterval( fn, time
From: jeff w
I am new to jQuery, and have started to play with JSON,but I
need some info about how I refer to the JSON Object once it
is returned from the server. I know I can loop through the
contents of the object, and I can use json.count, but I am
really unsure about the correct
I've been hacking with jQuery on and off lately and I've
now hit the annoying problem of not being able to access
simple DOM 0 properties unless, apparently, using either
of the following syntaxes:
$('#foo')[0]
Will throw error if there is no match, IIRC.
No, it won't. It is
.
--Erik
On 8/16/07, Michael Geary [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
wrote:
From: jeff w
I am new to jQuery, and have started to play with JSON,but I
need some info about how I refer to the JSON Object once it
is returned from the server. I know I can loop through
So, should I treat my JSON object like a Javascript
multi-dimensional array?
Seeing as how JavaScript doesn't *have* multi-dimensional arrays, I probably
wouldn't put it exactly that way. :-)
But you definitely have the right idea. JSON is simply a text representation
of JavaScript objects,
$('#foo')[0]
Will throw error if there is no match, IIRC.
No, it won't. It is not an error to fetch a nonexistent
array element
Thanks for a nice explanation. I'm sorry for jumping
without reading it properly.
Glad to help - but no apology needed! You should see some of
From: Pops
Ive seen this term referred to a few times, especially here:
http://simonwillison.net/2007/Aug/15/jquery/
What does Unobtrusive Javascript mean?
I'm going to disagree slightly with some of the earlier replies. I think
progressive enhancement and unobtrusive JavaScript are
yes I know about strings and numeric conversions. I want to
know is there a way to force json to force values to strings.
I have played with the parser but it is a PITA and played
with adding at the query level but that is too
cumbersome. I can't believe JSon does not have any
Good ideas, Thiago. The second one - nested AJAX calls - will definitely
work, and it is probably the simplest way to do this:
$.getJSON(url1, {}, function( json1 ) {
$.getJSON(url2, {}, function( json2 ) {
// do something with json1 and json2
});
});
That does serialize
I am trying to get event bubbling to work right and have this snippet
$(div).click(function(event) {
if (event.target == this) {
$(#text800birds).css( { background: #EE, color:
#FF} );
}
});
I would like to change this part
Meaning, is this following valid?
var inputBox = $('input').attr(type, text).attr(id,
someText);
.
.
inputBox.appendTo('#myForm');
inputBox.appendTo('#myForm');
inputBox.appendTo('#myForm');
In my testing, that doen't work. It only adds the first one.
A single node
From: MrNase
I have the function called init() where I use Ajax.get to
fetch the list and I have several other functions but writing
them down like:
$(document).ready(function() {
init();
otherfunction(); // booth need the data provided by init();
function();
});
It would be helpful to have a complete example of your actual HTML and
JavaScript code. The code you listed in your message is not working code:
1) The selector $(#example tbody tr td.name) will not select anything,
because your td's have no class attribute.
2) $(this).html().indexOf(val)
I just noticed one tiny bit of dead code in the function I posted:
var row = rows[i], col = row.col;
Can be:
var row = rows[i];
Since the col variable is unused.
-Mike
My row column contains lot of details apart from name like
images span id's apart from just text as in your scenario. in
precise it contains lot of details apart from simple text but
I need to pick up only that text from column by which rows
are to be hidden.
This is example to give you
From: Dan Eastwell
I'm doing an order form for a bookstore. The order form has
over 500 items in it, so jquery runs slowly...
Can't you do any of this on the server? All of the code generation - the IMG
tags and the zebra striping - would cost next to nothing while the page is
being
From: Dan Eastwell
The thinking behind it is not to add the button images using
javascript, so that if you don't have javascript, you don't
have useless and confusing buttons.
You can still generate the code on the server. Just use this code in head:
style type=text/css
From: Michael Geary
Then, instead of binding event handlers to all of the individual
buttons, just bind a single event handler to the parent form:
$('#order_form').click( function( event ) {
var $target = $(event.target);
if( $target.is('img.increment') ) return
1 - 100 of 873 matches
Mail list logo