$().ajaxStart( function ) and $().ajaxStop() are great to
show/hide a global Ajax activity image/message. But sometimes
it would be nice to temporarily inactivate this functions.
E.g when you have a very short Ajax request, showing an image
for a second or so is more annoying then really
alert($(#btn_save).disabled);
you may .get(0) to get the (first and only) element of
$(#btn_save) :
alert($(#btn_save).get(0).disabled);
I'd have thought by using the ID selector there should only
be one object returned anyway.
$() always returns one object: a jQuery object. It
Now the problem: When I clicked the download link and tried
to scoll right to view more of the page Firefox actually
crashed --and I mean bad. It locked up my whole system.
Don't shoot the messenger, but something is wrong with your system. Firefox
shouldn't be capable of locking it up like
http://laurens.vd.oever.nl/weblog/items2005/closures/
Has this been found to be an adequate solution to this issue?
(mainly for non jquery code)
Yes, it solves the IE closure problem very nicely. My closure plugin for
jQuery uses a modified version of this code.
-Mike
You are not sending down a Content-type: text/xml header, so the browser is
interpreting your XML as plain text.
To confirm this suspicion, change your alert to:
alert( xml );
You want the alert to display something like [object XMLwhatever]. Instead,
it will probably display the actual XML
Yesterday scientists agreed about the fact that Pluto
shouldn't be called 'Pluto' anymore, but 'Dwarf' from now on.
The name is choosen because it's the smallest (discovered)
planet in the universe, and a so called 'dwarf'-planet..
Not true!
Yes, Pluto is now classified as a dwarf planet
The advanced event plugin creates three $() methods for each event: a
binding method foo(), a one-shot binding method onefoo(), and an unbinding
method unfoo().
Two of the events that this plugin wraps are the load and unload events.
Therefore, $().unload() can be either the unbinding method for
From: Ferdinand Beyer
What I would really like to see in the standard library is
that jQuery objects can be passed to the $() function to
obtain a copy:
var $a = $('some.query');
var $b = $($a);
$b.filter('some.criteria'); // Does not affect $a
It looks like jQuery 1.0 does this.
Have you considered using goggle projects
(http://code.google.com/hosting/) to host the central latest
file and maybe related plugins?
The reason I mention it is because we can all benefit from
caching to load the file quickly. Also, I think the
popularity of jQuery is going to grow
interface is a reserved word.
http://javascript.about.com/library/blreserved.htm
I guessed somethink like this already...
Stefan (Petre), is there any quick fix available / possible?
:-) Thanks, Arash
You could edit the code and change that word to see if it fixes it. The
function in
From: Dylan Verheul
Actually, in DOM terms, zIndex is the only correct name.
From: aedmonds
Right... but for CSS properties I believe z-index is the only
correct name for the zIndex property. Maybe I'm wrong but do
know you set zIndex by using
p { z-index: 2; }
I guess I've
From: Albert Garcia
I will thanks JQuery developers community specially John
for this incredible library.
We've been using it during the redesign of our software
download portal's program page, wich is finally online in our
german site: http://www.softonic.de . It has helped us
From: Michael Geary
I could probably track it down but I haven't had any coffee yet...
From: Klaus Hartl
Someone bring Mike a coffee please!
Ah, thanks, Klaus, John sent one over by FedEx Instant Delivery (and it was
good coffee, not instant!).
From: Albert Garcia
Although, I've
Does jquery have something like $H() ?
I'm trying to convert a prototype based script
var a = $H({
a1: [1, 2],
a2: [3, 4],
});
and
a.each(function(n) {
var v = $H(n).value;
});
how would I do this in jQuery?
What does it do?
-Mike
From: Jonas Galvez (via Patrick Hall)
Is there any standardized way to preserve context when setting
callbacks within an object's method? Here's how I see it is done now:
function Editor() { // class Editor
var self = this;
$(document).ready(function() { self.doSomething(); });
}
From: Yehuda Katz
1) Is it possible to easily get the current focused field?
2) Is it possible to programmatically get the cursor to blink
in a text field?
Hi Yehuda,
I wonder if you saw my reply to your previous message on this topic:
http://jquery.com/discuss/2006-September/011349/
I did see your earlier comments. Unfortunately, any click
event unblurs inputs. I've gotten around it by tracking the
focus using a global variable and reassigning it using the
DOM method focus().
Oh rats, what was I thinking. You're right, of course. Sounds like you have
a good solution
From: Blair Mitchelmore
If I'm not mistaken, anything can be used as a key if
enclosed in quotes:
f = {float:right} // no problem
Rather than with implicit quotes:
f = {float:left} // not so good
They can then be accessed via the array accessor
f['float']; // no problem
From: Stefan Nagtegaal
i want to port some pretty large JS-file to jQuery to take
advantage of the easy way of writing and understanding it.
Problem is, I never did much JS before..
Could you guys give me some workflow for what the best way
would be to start and finish such a job?
Any
$.fn.checkform = function() {
$(this).bind(click, function(){alert(it works);} );
};
What am I doing wrong ?
Ok I got it:
$.fn.checkform = function() {
return this.each(function(){
$(this).bind(click, function(){alert(it works);} );
});
if (!window.GBrowserIsCompatible || !GBrowserIsCompatible()) return
this;
Is also possible?
if ( !(window.GBrowserIsCompatible GBrowserIsCompatible()) )
If you don't say yes my headache gets worse!
Don't get a headache, Klaus, that is fine and reads better too. After all,
!( a b )
I need help to make the following code works in IE :
document.writeln(select name=\+name+\
id=\+name+\+((multiple!=null)? +multiple:)+);
var tablename = some_table;
$(#+name).load(table_query.php, {table: tablename});
document.writeln(\/select);
Script
From: Dan Atkinson
Also, I'm unsure why you want to use document.writeln as I
find jQuery's methods much more compact and neat.
I don't know if it relates to this specific code, but there are things you
can do with document.writeln that you can't do with DOM manipulation.
Specifically, the
Is it permissable to have more than one
$(document).ready(function() {})
per page?
Yes, as many as you want. They will be called in the same order that the
$(document).ready() calls were made.
Note that there is a handy shortcut for $(document).ready():
$( function(){} );
-Mike
Before y'all get too excited about this, keep in mind that it affects maybe
one visitor out of ten thousand.
The only people who run into this flicker problem are those who have gone
into Internet Options / Temporary Internet Files / Settings and changed the
check for newer versions setting to
He's been sick man.
From: Rey Bango
John! Where the heck you been man? We've missed your input here. :o)
Rey,,,
John Resig wrote:
Woah - do you design for Quickbooks? That'd be hot :-)
I really like the slidey menu - hidden, but useful, navigation.
--John
Here's a pattern that occurs frequently that I'm really
curious about:
new function() {
// do stuff
}
Is the purpose of this just to provide local scope to the
variables used?
Yes, that is the one and only reason for it.
Is there an equivalant syntax that may be
more common?
From: Klaus Hartl
is it possible to use $.extend to clone an object?
var template = { ... };
clone = $.extend({}, template);
To answer my question, yes it works :-)
Keep in mind that extend() does a shallow copy, not a deep copy.
var one = { a:1, b:{ c:2 } };
var two =
From: Mike Alsup
Seems to be faster rewriting it with a for loop instead of using each.
Matt, can you confirm?
Here's a skeleton of another way to approach the problem. Instead of
enumerating every element inside the form, it looks at each nodeName as it
goes and decides what to do from
From: Mike Alsup
Mike Geary, I haven't yet implemented your outline.
I like it stylistically, but I not expecting performance
improvements. Would you agree or would you
expect it to be faster than Renato's impl?
I think it depends on the nature of the form. For a form with a SELECT
Even if your not using the interface plugin you need down load
the iUtil plugin and start using it. I even think that iUtil should
go core.
A link would be terribly useful when promoting something
this hard. :)
I don't want to hot link the file, but you can find it here
From: Joel Birch
I am obviously missing something here - can we not just have
some sort of friendly web interface that retrieves the latest
version of jQuery and whatever else this Ant build gives
you? This seems like a high barrier to entry considering the
potential demographic that
Sam was correct that I wanted the latest SVN version. I also
wanted to see if I was missing out on any other information
that the build process provided.
@Michael: I got the idea that it would be a good thing to
have access to this from what John Resig mentioned when 1.0
was released.
Nice.
You could simplify this:
var f = ['INPUT', 'TEXTAREA', 'SELECT', 'BUTTON'];
$(f.join(','), this).each(function() {
to:
var f = 'INPUT,TEXTAREA,SELECT,BUTTON';
$(f, this).each(function() {
BTW, what do you mean when you say it isn't a plugin? Looks like one to me.
:-)
$.fn.checked = function(b) {
if ( b || b == undefined )
this.attr( checked, checked );
else
this.removeAttr( checked );
};
I strongly suggest you to compare if a variable is equal to
undefined using the typeof unary operator, because if you,
someday, dicide to
From: Dossy Shiobara
I'm surprised there's no .reverse(). i.e.:
$(collection).reverse().each(...)
Great idea!
How about the world's smallest plugin:
jQuery.fn.reverse = [].reverse;
Try it out at http://jquery.com/ by entering these lines into the FireBug
console:
jQuery.fn.reverse = function() {
this.pushStack(this.get().reverse());
return this;
}
Nice. That is a better approach then just doing
jQuery.fn.reverse = [].reverse.
I'm curious, what is the advantage of one approach over the other?
-Mike
From: Stephen Woodbridge [EMAIL PROTECTED]
http://imaptools.com:8081/maps/demo2.html
From: Brent Pedersen
i'd guess the offending line is in mscross:
Object.prototype.objRef = null;
Good catch. It's strictly verboten to add to Object.prototype. That will
break all kinds of things, not
Thank you very much! That was it.
[Object.prototype.objRef = null;]
Any idea why that would have been done in the first place?
Probably because the person who wrote that code didn't know any better!
I ran into another issue that all my for loops in code I added to
mscross were
Does anybody know if it is possible to run both IE 6.x and
IE7 both on thesame system? An absolute must if you are
a web developer...
Use VMware and you can run every version of IE, and Firefox, and any other
Windows browser you want to test.
http://www.vmware.com/
-Mike
From: Brendan O'Brien
I have a somewhat related observation. I have discovered
that when selecting by ID, the context parameter does not
matter. In other words, these two statements are
functionally equivalent:
$(#myId);
and
$(#myId, myContext);
It's as if when the id selector
From: patrickk
I´m using the plugin for DOM creation to accomplish that. see
http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype
From: Rey Bango
I tried using this plugin but it didn't seem to work with
v1.0.1. Which version of JQuery are you using?
Rey, which of the
I really prefer doing a 'return false' instead of throwing exceptions.
It just feels like an incredibly messy way to handle things -
plus it prevents you from writing good one-liners, which makes me sad.
Plus the change is trivial, too:
each: function( obj, fn, args ) {
Sanyi, "this" is not the same when you're inside a nested
function.
Add this line of code at the beginning of
showFlash:
var self = this;
And then change "this" to "self", and you'll be in
business. (You can use any variable name instead of "self"; that's just a common
choice.)
Also,
Don't use underscores in element IDs. It's not a valid
character, and some browsers (like, MSIE) will not do what
you want if you use it.
http://devedge-temp.mozilla.org/viewsource/2001/css-underscores/
Use hyphens, if you insist on using a visual separator.
That's not quite right.
Authoring guidelines say Always use jQuery instead of $
inside your plugin code - that allows users to change the
alias for jQuery in a single place. Does this mean only
the first line jQuery.fn... or should also extend be
jQuery.extend()?
That means everywhere inside. So if you did
Use the SVN version if you want to do that sort of thing.
http://jquery.com/src/ - Shows you the SVN access address.
AFAIK this has to be built first before it is usable. I am
looking for readily built snapshot.
No, it doesn't have to be built. The svn code is usable right out of the
I imagine that it must be some way to use javascript variable
for HASH... Is it possible?
I show you the code that I'm using (and it show me an error
in FireBug (Firefox):reference to undefined property imts):
function LoadAjax(t,d,id){
var itms
itms='{url: GetValues'+t+'.asp, type:
Well, as I've already said, you won't be able to show the PDF
in a thickbox, because the OS/browser will catch the link and
try to open it using the default action set in the browser or
OS, and there's nothing that you can do to override it. If no
default action is set, then you -might-
From: Klaus Hartl
I wanted to add the normalization for e.target as discussed
earlier. But I came across a strange bug in Firefox. Have a
look at the following page:
http://stilbuero.de/demo/jquery/etarget.html
If you click on the link the target of the click event
(attached to p)
In Jörn's version of the code, you wouldn't call $.query() at all. Instead,
$.query would be the resulting object that you would then use directly. Note
that jQuery and $ are references to the same object, so jQuery.query and
$.query are the same thing.
I'm not sure I like this idea since it
$(function(){
$('head').append('link rel=stylesheet href=jquery.css
type=text/css');
});
That's pretty dangerous. The CSS file will load asynchronously, and you
won't know when it's done. In the meantime, any content in the page may
render unstyled. You are likely to get a flash of
I would like to be able to load my jquery plugins dynamically
as this would reduce the number of scripts in my document head.
You can easily load any .js file dynamically, for example with code like
this:
function addScript( url ) {
var script = document.createElement( 'script' );
how do I search for a children within a context?
In other words, how to translate this:
$(context).children(dt)...
into something like this:
$(/dt, context)
The latter one does unfortuanetely not work...
I'm confused - could you give an example with some HTML code and show
exactly
From: Klaus Hartl
Just wanted to note, that dynamic script elements are
not supported in Safari 2.0. Support for that was added
in Safari 2.01.
Hmm... It works in older versions of Safari. I just tested it in 1.2. Are
you saying the support was removed (or broken) in 2.0 and put back in
Do you really need an object at all? This (pun intended) would do the same
thing as all the code you listed:
$(function() {
var $btn = $('#btnCounter'), nr = 0;
$btn.click( function() {
$btn.attr( 'value', nr++ );
});
});
-Mike
From: Kolman Nándor
I am new
I was wondering having done:
$(.foo).click(function (e) {alert (foo);});
Can I force the click event to fire manually, or do I resort to
var x = function (e) {alert (foo);}
$(#foo).click(x);
ele = $(#foo).get(0)
x.call( ele, {target:ele});
You can use either of these (they do the
1) Where can I find a searchable archive of this mailing
list, because I'd hate to ask questions that have already
been answered.
Here are a couple:
http://www.google.com/search?q=site:jquery.com+optimize+OR+optimization
http://www.nabble.com/JQuery-f15494.html
2) I'm getting about a 1.5
humpf, I don't understand why I can't modify the title tag
with jquery...
I want to input some data after its loaded. For example,
$(title).append(test);
How come this does not work?
You can't change the title tag's innerHTML once the tag has been encountered
in the HTML code. This
You can't change the title tag's innerHTML once the tag
has been encountered in the HTML code. This isn't a
jQuery limitation; it's a browser limitation.
I don't know if it is true for every browser, but it is for
the ones I tested when I implemented dynamic titles a
while ago.
Simon, you've run into one of the more confusing things about jQuery. I
think it's safe to say that jQuery code would be easier to understand if it
used explicit function arguments everywhere instead of this. (There are
other advantages of using this, but it is definitely a mixed blessing.)
Every
To answer my own thought, I remembered it's a problem with
the way many external COM controls work because they're not
native Javascript objects.
This post explains the situation a bit:
http://blogs.msdn.com/ericlippert/archive/2004/09/20/231852.aspx
Although IE cooperates with
From: Jörn Zaefferer
I actually managed to release my first official and
documented jQuery plugin, a Tooltip implementation. It
doesn't use AJAX, nor extra markup, only title and href
attributes and some styles. You can customize the delay after
which it should be displayed, default is
http://bassistance.de/index.php/jquery-plugins/jquery-plugin-tooltip/
A suggestion - perhaps you should use 'jQuery' instead of '$'
as isn't that the convention for plugin authoring?
The code does use jQuery instead of $. Jörn used the trick I suggested a
while back to get the best of both
From: Paul McLanahan
The only suggestion I have deals with displaying the tips
close to the right side of the screen. You do an excellent
job of handling the width of the tip when it is close to the
right edge of the window, but if a word is too long inside of
the tip it will push
From: Simon Corless
Thanks for the help Mike, it's starting to come together.
I've been testing it just now.
If I do use return this.each() then how do I reference the
jQuery methods? without this.hover() etc? Obviously as this
is no longer what I am expecting this.hover (as you say)
why doesn't this work:
$('#text-field').val(this.name);
What is this? You haven't given it a value. So it depends on the context
of this code. If the code is not in an object method, then this is the
window object.
when this does:
$('#text-field).click( function() { alert(this.name); }
From: Michael Geary
(function($) {
// plugin code here
})(jQuery);
From: Sam Collett
I've seen that used before, but can it have memory leak
or other issues?
Sorry about the very slow reply, Sam.
That's a good point. The use of the closure could result in memory leaks
From: Laurent Yaish
I couldn't find a way using jQuery to get the tagName of an element.
Let's say I have this:
divspantest/span/div
$('span').parent().tag() would return 'div'
From: Brandon Aaron
You could do two things ... write yourself a plugin that
would look something
And to make it valid JSON, you have to quote all keys anyway
(using double quotes):
{ asJSON: 1, class: jlink, id: htmlDoc }
http://json.org/
Naw, that wouldn't be valid JSON. JSON doesn't allow named references like
htmlDoc.
But this object doesn't need to be JSON anyway. It's just an
I don't think this approach will work quite the way you'd like. In your
example:
// I access my plugin via:
$(#myMap).Map({ options hash });
// later I can access a public function on this object like:
$(#myMap).Map.recenter(x, y, dxy);
Those two $(#myMap) calls are going to result in
From: Truppe Steven
my view of the things is a big different. I think jquery
should stay as small as possible so adding functions for
basic dom attributes is a bit overhead i think ..
I agree. How do you decide which of the many DOM attributes to turn into
jQuery methods? All of them?
When you have a problem like this, your first thought should be to look at
the generated HTML using Microsoft's DevToolBar in IE or either FireBug or
View Source Chart for Firefox.
I moved Testnode up and then moved it to the right, then used FireBug's
Inspect tool to reveal the generated HTML.
I moved Testnode up and then moved it to the right, then
used FireBug's Inspect tool to reveal the generated HTML.
This is what I saw:
Actually I left out part of it by mistake. Here's the entire UL:
ul id=nodes class=sortable
li id=node5 class=sortableitem/li
li
One more comment... As you probably figured out from looking at the
generated source, the culprit is likely to be the animation code, which sets
those unwanted attributes when it animates an item.
So one good test would be to remove all animation and see if it generates
better code.
It will also
From: Andrea Ercolino
I have got an array of 50 urls templates, and want to make a
proper url out of each one, adding also a special click, and
then append all these urls to a div in a specific position.
All this should be done many times in a page, many could be
50, just to say
From: Michael Geary
Yeah, all that DOM creation will take a while - especially
if you use a convenience plugin like mine.
I get much better performance across browsers with
[].join('') and innerHTML.
From: Dave Methvin
There don't seem to be that many situations where DOM
So...the lesson is...the jquery.js file always has to be
included for the jQuery code to work and it has to be
referenced first...correct?
It doesn't have to be *first*, but it does have to be before any code that
uses jQuery.
Think about it this way... Would this code work:
alert( x );
In the .css method an array is created by:
d = [Top,Bottom,Right,Left];
Then it is looped through using object looping:
for ( var i in d ) {
This probably isn't a problem for most people, but we have
added functions to the Array prototype, so whenever the .css
method is used it
From: Kevin Old
I'm parsing some json successfully below, but I'd like to be
able access the contents of the json object like
this.[id] or this.[name].
function processData(json) {
$.each(json, function(i) {
$(#names).append(ID: + this[0] +
But, I would be sad to see .click, .hover, and .toggle go away, if
they are among the helper functions you plan to put into a an
external plugin. They just make so much more sense than bind to
people new to programming/javascript/jQuery.
I am not a fan of bind either, I'm sure it was
Our company is looking for a way for 'quick' web-development.
Small webapps consisting of a few webpages with some minimal
database interaction.
We currently develop everything in Java (including webapps),
but I find the whole cycle of developing, compiling (java
class files, EJBs
Why not use document.createElement(script) !?
Because we want jQuery to wait until the script is loaded and
evaluated, so it's possible to do something upon completion,
like continuing the normal flow of the program. This is
necessary for example for writing a require like the one in
I really have no idea what is the correct name(I'm not a
javascript guru), handle is a function in function(or jQuery?) scope?
You know , i just copy your code structure. xD
Demo page:
http://61.191.26.228/jQuery/plugins/modal/test.html
Your functions named plugin, modal_handle,
From: Michael Geary
Also, that comma after the } shouldn't be there. It looks like you
picked up the use of the comma from object literals...
From: Jörn Zaefferer
Actually there is a single var at the top, therefore the
problem must be somewhere else... My fault, I should
remove
This has nothing to do with jQuery, but I'm hoping that some of you
might have seen this and figured out how to make it go away. I have
googled for it, but nothing helpful showed up.
not jquery. I get a bunch of errors each time I start up ff
2... they don't recur. do yours?
Did you
From: Adam Skinner
I'm trying to reference an element from within an iframe.
The following normal javascript code works:
var iframeDoc = window.frames[iframeName].document;
var data = iframeDoc.getElementById(iframeElement);
I'm trying to jqueryize the data variable as
I had to do something similar today, and I did something like
function myfunction(f){
$(element).click(function(){eval(f+(););});
}
that was off the cuff, but that should work.
That would be the ticket if f is a string containing the name of a function.
But why not just pass a
You're using the variable j to hold a reference to each element of the
jobs array as you go through the loop. After the loop finishes, j is a
reference to the last element of that array.
Later, when the click function gets called, j still refers to that last
element - regardless of which element
I suppose this touches on off topic, but ... is it possible
to remove an entry completely from a JSON hash?
say I have
{
firstString: 'first',
secondString: 'second'
}
and evaluate this into a json object, and I want to remove
firstString, could I do something like
I suppose this touches on off topic, but ... is it possible
to remove an entry completely from a JSON hash?
say I have
{
firstString: 'first',
secondString: 'second'
}
and evaluate this into a json object, and I want to remove
firstString, could I do something like
Try this (untested):
$(function() {
$('.y').html( (new Date).getFullYear() );
});
-Mike
p.s. Could we avoid profanity on the mailing list? Thanks.
_
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kristaps Ancans
Sent: Tuesday, December 19, 2006 12:44 AM
To:
Not only not related to jQuery, but not related to closures either. :-)
The problem is that setTimeout doesn't accept the additional arguments you
are passing it.
Is there any reason you can't do this:
setTimeout( function() { doStuff( stuff, 1, 2 ); }, 100 );
That would work in any browser.
this doesn't work like a local variable. Inside a nested function, this
is not the same as in the outer function. That's what is messing things up.
If I understand your code, you can write it more simply like this:
(function($) {
$.fn.Tooltip = function(settings) {
var $all = this;
If you're just trying to load a stylesheet dynamically, all you need to do
is this:
function addSheet( url, doc ) {
doc = doc || document;
var link = doc.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = url;
From: Michael Geary
If you're just trying to load a stylesheet dynamically, all
you need to do is this...
Just to be clear, I wasn't disparaging jsPax!
It just depends on whether you need a full-featured package system or a
simple loading function.
-Mike
...since the spec requires name and ID to be
identical, it's technically illegal to have a name with [
and an ID as well (since IDs cannot contain [).
Um, where does it say the name and id have to be the same?
-Mike
___
jQuery mailing list
Done a test (requires Firebug - or Firebug lite (which I presume would
also work)).
var foo = [one, 2, three, new Date()];
$.each(foo,
function()
{
if(this === 2) return false;
console.log(typeof this);
}
)
This logs:
[o, n, e]
2
Would you like an Array iterator that works the way you'd
expect? Here is a simple one:
Array.prototype.each = function( yields ) {
for( var i = 0, n = this.length; i n; i++ ) {
if( yields( this[i], i ) === false )
break;
}
};
I'm afraid that I simply don't take Safari users into
account. Hardly a great thing, but I focus on three
browsers: Firefox and IE7, and then IE6.
In that order. The work I do is targetted at corporate
users who run Windows 2000 and Firefox, and all the
JS work I do is for those
1 - 100 of 146 matches
Mail list logo