I want to make a remote request to a different server than
the current page is hosted on, in order to get JSON data
(padded with a callback).
This is typically handled by inserting script elements on
the current page with the src as the remote URL, (Right?),
but I couldn't find an easy
This works for me:
$.ajax({
url: 'email.pl',
type: post,
data: {
rm: 'deleteLetter',
ID: myForm.letterSelect.value
},
dataType: 'json',
success: function( ret ) {
alert( ret.a );
}
});
I believe the order in which you pass the
I was poking around the DOM looking for incorrectly scoped
variables and I found the following node:
window.undefined = undefinedundefined
What is this for?
The window object has a property named undefined whose value is the
undefined value.
IOW, when you run code like this:
if( foo
I'm having trouble seeing the advantage of adding static
functions to jQuery as in:
jQuery.log = {
error : function() { ... },
warning : function() { ... },
debug : function() { ... },
};
as opposed to:
function log() { ... }
log.prototype.error = function() { ... }
Is there a way to change the title of a document after an
ajax Call. I'm using an ajax history system and I would like
to view specific document title in the back button list.
I've try this but doesn't seem to work :
$(title).html(Dynamic Title);
I can see the change in
Nothing to do with SEO. The display and visibility properties do two
different things:
http://www.w3.org/TR/CSS21/visuren.html#display-prop
http://www.w3.org/TR/CSS21/visufx.html#visibility
-Mike
_
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Microtoby
Sent:
Now, my mark-up is wrong. I should have wrapped the nested
ul in it's own li, but I missed it. Testing looked good
in FF 2, .next() was returning the nested ul, and I didn't
even notice the problem. In IE6/7 however,
.next() returned the next li, and not the ul which was in
fact next
This is untested code, but it's one way you could do it with jQuery:
$(function() {
location = $('[EMAIL PROTECTED]')attr('href').replace( /_spam$/, '' );
});
_
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Christopher Jordan
Sent: Saturday, February 24, 2007
: [jQuery] KICK-BUTT javascript based Zoom feature
Wow. that looks simple.
I guess the jQuery core has everything else needed to
produce the close-up effect?
Rick
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Michael Geary
Sent: Saturday, February 24, 2007 2:07 PM
To: 'jQuery
...and if I seem too much like a smart aleck today, my apologies! No offense
intended. I was just having some fun with the juxtaposition of that URL is
busted and anyone know how to accomplish this in jQuery... :-)
_
From: Michael Geary
The actual code for the close-up effect would
You may use a period in an id still being valid XHTML, but in this
case you cannot use the id as a (CSS) selector, because the
period is a class selector.
I'm not convinced it's not a bug in jQuery because it doesn't
make sense to specify a class on an Id. I'm not going to make
a
What if I specify a div as display:inline in my css? Hiding
then showing this div using the above script would change
it's display to block.
Good point!
I was about to suggest making a list of the block level elements to avoid
having to create DOM elements to test, but either approach would
elem.style.display=block when there is a speed
designated. Plain .show() returns them to inline.
On Feb 14, 2007, at 5:37 PM, Michael Geary wrote:
The real problem here is that there is *no such thing* as showing an HTML
element. All you can do is set it to block or inline. This suggests that
show
I'm trying to get some simple things to work using jquery,
and everything currently works the way I'd like it to in
Firefox. However, in Opera, Safari, and Internet Explorer,
nothing works right -- and I haven't been able to figure out
where the hang up is.
My entire jquery code can
$.get(parser.php,
{
type: type,
user: user,
},
trailing commas only work in firefox!
user: user,
has a trailing comma!
Great catch, Jake.
Here's a tip - use ActiveState Komodo for your JavaScript editing, and get
syntax checking as you
There are several ways you could refactor that code. Here's one approach:
$('#normal, #standard, #profi').click( function() {
var idnums = { normal:1, standard:2, profi:3 };
$('#bereit').ScrollTo( 800 );
for( var id in idnums ) {
var n = idnums[id];
As you can see from your first (presumably working?) example, .contentWindow
is a property of an HTML element.
Therefore, the real question is, How do I get the HTML Element?
If you are inside an $('foo').each() callback function, then this is the
HTML element. So, you could use:
I have a quandary. I open an iframe with some arbitrary
content in it. I want to be able to click on something within
the iframe to cause the iframe (and the div tag that contains
the iframe) to go away. I am having trouble getting to the
iframe. I know it's possible as I've seen it
I was able to take what you sent me and simplify it down to this:
var frameWindow = document.parentWindow || document.defaultView;
var outerDiv = $(frameWindow.frameElement.parentNode);
cls = $('div.tb_close', outerDiv).get(0);
Because I actually want to operate on a
Recently I've been trying to use ON with jQuery. I met with obstacle.
I couldn't use this keyword in certain cases to get my main object
reference...
var myObject = {
layout: { 'align': '' },
start: function() {
$('form').bind('submit', this.buildLayout);
If you change only the hash, it won't reload the page - but it won't create
a unique URL for search engines. If you change anything else in the URL, it
will reload the page.
Changing the hash does get you a URL get people can copy and bookmark. But
Google won't see the hash.
It really is a case
I'm trying to get animate() to fade font-weight but it's not working.
I've tried the following:
$('a').mouseover(function() {
$(this).animate({fontWeight: 'bold'}, 'slow'); });
But that doesn't work - I've also tried to put quotes around
the fontWeight and tried font-weight.
I get
$.fn.border = function(prefix){
var classNames = [ 'north', 'east', 'south', 'west', 'northeast',
'southeast', 'southwest', 'northwest'];
return this.each(function(){
for (var index in classNames){
className = (prefix || '')+ classNames[index];
$(this).wrap(div
When you create a named function is is basically a static
object stored in funcname of the scope it was defined in.
when you declare a var in a function it is also a static
object attached to the function object. As such mydata is a
single static object and effectively a single object in
$(document).ready(function(){
function resizeDiv(that){
var x = $(that);
if(x.height() 600){
x.css(height,600px);
}
};
$(#mydiv).each(function(){resizeDiv(this)});
});
My question: is it better to define this function as above
and pass this or to define an
I'm not very familiar with InnerFade, but wouldn't you do this inside your
marker click handler, right after you call marker.openInfoWindowHtml? That's
when you have the list items available.
I'm new to jQuery and am trying to figure this out, but was
wondering if anyone has had any luck
!-- ... - is an HTML comment, not a CSS comment. So, conditional comments
go in your HTML code, not in CSS code.
div.SiteHeader{
border: 1px solid #336566; /*AA*/
width: 850px;
background-color: #E3F0D6; /*D5F0D5,CDD9E5*/
height: 60px;
text-align: left;
margin:
!-- ... - is an HTML comment, not a CSS comment. So, conditional
comments go in your HTML code, not in CSS code.
Michael, so that only works with inline styles?
You can use them with any HTML code. Inline style tags, link tags,
script tags, whatever.
Do a View Source on www.zvents.com for
Is there a way to just return the jquery object (so I could
see it in firebug's watch section) then pass it to another
jquery function then join them all up when I know
everything works?
$('#test :textarea').before('Current length:nbsp;span id='+
this.id
The DOM updates immediately when you add new elements. But updating the
DOM does not mean copying event handlers from deleted DOM elements to
newly added DOM elements. That appears to be the problem here: You need to
assign the click handler again after replacing the DOM element, because the
click
That's a nice trick, Jake - thanks for posting it!
Both approaches have their use. Your log plugin is great for console
logging, while breaking up the chain is great for interactive debugging
because you can set a breakpoint between lines.
-Mike
Mike, I don't like breaking the chains... I just
// this is .n much too complicated!
Guys, I don't appreciate the profanity. My 10 and 11 year old daughters are
learning JavaScript. I don't want them to be subjected to language like
that.
When you've offended some people already, offending more is probably not the
best way to fix it.
Guys, I don't appreciate the profanity. My 10 and 11 year old
daughters are learning JavaScript. I don't want them to be
subjected to language like that.
Just to clarify, my daughters don't actually read the jQuery list - yet.
Their goal is to make an online computer game for some of their
From: Michael Geary
Just to clarify, my daughters don't actually read the
jQuery list - yet. Their goal is to make an online
computer game for some of their friends to play.
Right now they're just learning about variables and
loops and a bit of HTML and CSS. Hopefully
(If there is a better way to look at the Object, please post here)
The very best way to understand what JavaScript code is going and explore
objects is to use any JavaScript debugger, such as Firebug or Venkman for
Firefox, or the Microsoft Script Editor for IE.
If you don't have a JavaScript
Now that it is laid out in front of me it's pretty obvious,
but when you come into the thing cold, these things are not
obvious. I think it would be a good idea to explicitly state
what the object is, and that $ refers to it (I think that's
right ... now I mention it I'm not quite sure if
if have some thing like this that is called by document.ready():
function init_top_level() {
$(.top_folder).click(function(i) {
// Do a ton of stuff here
});
}
I not only want to assign the click event to my .top_folder
elements, but assign dblclick as well. I
Forgot to add us to the list...
Zvents:
http://www.zvents.com/
This is a Rails site and we completely replaced prototype.js with jQuery and
our own code. We're using thickbox, a homegrown autocompleter, my DOM
plugin, and lots of custom code.
This also puts jQuery on our partner sites:
The
Thanks for the assistance. Yes, I was basically trying to
assign a click and dblclick to the same function (to prevent
users from double-clicking and firing the func twice).
Hmm... If you assigned both click and dblclick to the same function, then
the function *would* be called twice on each
Scripting on top of an invalid HTML document won't make
your life easier (obviously). I'd try to replace spaces given
by the user to _ in the backend.
And then do what with underscores given by the user?
Come on, that was just an idea. You can leave underscores the
way they are for
var a[];
$(':checkbox').each(function() {
if (this.id) a.push(this.id);
});
I get this error:
missing ; before statement
var a[];
(curse my rudimentary javascript skills!)
OK... It says there is a missing ; before the statement var a[];.
What is before the
Do you want getPost to be called during the execution of initialiseForm, or
later in response to the 'submit' event? For the latter, use this (added
code in red):
function initialiseForm(formId) {
$(formId).bind('submit', function() { getPost(formId) } );
}
-Mike
_
From: [EMAIL
$(function(){
$(div.OrderEntryListRow).not(.Selected).each(function(i){
alert(before: + $(this).attr(id));
$(this).attr(id, Row_ + (i+1));
$(this).html($(this).html() + ': ' + (i+1));
alert(after: + $(this).attr(id));
});
});
Any time you see
Chris, it's like this... ;-)
$() returns a jQuery object, which is an array of DOM elements with jQuery
methods that apply either to the entire array or to the first element in the
array, depending on the method.
One of those methods is .each(), which loops through the DOM element array
and
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
Andreas, if I remember correctly, the following should work:
$.each(object, function() {
return false;
});
That isn't supported. The necessary code was removed due to
unsolved problems. Actually the stuff that Michael just
posted would help a lot to solve it, though I'm not
this.id = 'NewValue';
alert( this.id );
I've got another simple question. Is this not how you set an element's
attribute? [from inside an .each()]
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
...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
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
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;
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:
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
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
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
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
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
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
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
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
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] +
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: 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 );
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
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: 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
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); }
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
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.
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
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
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
$(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
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
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)
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-
1 - 100 of 146 matches
Mail list logo