Just a little fun for Halloween 2009.
I carved my pumpkin this year as the jQuery logo. I hope some in this
group can appreciate it! :)
http://mattkruse.com/2009/10/31/jquery-pumpkin/
Matt Kruse
rovide a simplified example case that you think is overly
slow, perhaps someone can identify other issues contributing to the
performance problem.
Matt Kruse
Used to debug this
> $('#msgsInbox input.messageCheckbox').attr('checked', $
> ('#msgCheckAllInbox').is(':checked'));
function checkAllMsgsIn(cb) {
$('#msgsInbox input.messageCheckbox').attr('checked', cb.checked);
}
Much simpler.
Matt Kruse
e more robust by doing:
if (openerFunc && typeof openerFunc.call=='function')
Matt Kruse
On Sep 2, 1:16 pm, msoliver wrote:
> if ($.isFunction(openerFunc))
Why not just:
if (openerFunc && openerFunc.call)
?
Matt Kruse
On Sep 2, 6:20 am, IschaGast wrote:
> I am having rounded corners in a site but I don't want them in IE
> because it does strange things with the corners.
Many non-IE browsers already have native CSS support for rounded
corners. If you want to exclude IE anyway, why not just use pure
x27;t change.
Then why does the example work in IE8 using jQuery 1.2.1?
You can certainly set a tr to display:none in IE.
Matt Kruse
settings are such that errors will be shown.
Matt Kruse
On Jul 9, 3:27 pm, Paulodemoc wrote:
> The generated code is
> http://servidor/astral/web/js/</a>
> jquery.js" type="application/x-javascript" >
> I tryied to add the
> alert('jQuery not load
r script url may be relative, and IE may be interpretting it
differently for some reason.
In any case, jQuery is not being loaded.
Try this:
<script language="javascript" src="<?php echo base_url();?>js/
jquery.js" type="application/x-javascript" >alert('jQuery not
loaded');
Matt Kruse
On Jul 9, 2:55 pm, expresso wrote:
> Also, do you really have
t I can then have jQuery
> use this, to get values from it? Or is there no sense in trying to
> use jQuery for this, and it might not even be of help?
Why would you want to use jQuery to handle a standard javascript
object?
What exactly do you want to do with it?
Matt Kruse
// A General "run" function to simplify coding
$.fn.run = function(fn) {
if (typeof fn=='string') { fn = new Function(fn); }
this.each(fn);
}
Then:
$(':checkbox.chkEvent').run("this.checked = !this.checked");
Whether that's actually more efficient to write depends on the
situation ;)
Matt Kruse
$(openMenu);
If you want a function to be available outside of the function scope
that is currently executing, then define it outside.
Matt Kruse
e(func) {
func();
}
Matt Kruse
this.checked = true;
jQuery should really have .prop() which would work like attr() usually
intends to, but deal only with DOM properties rather than trying to
manipulate actual attributes. Script authors usually want to deal with
properties anyway, and attr() only makes it confusing.
Matt Kruse
x27;show','hide');
You can pass in regex text, and it can toggle text within a string
like:
"Click here to show all items"
and it will just toggle the word "show" to "hide".
Hope it's useful.
Matt Kruse
On Jun 9, 9:35 am, simon wrote:
> $.myvariable1
> $.myvariable3
> $.myvariable2
> now I would like to add the number part of the variable to it
> dynamically.
var i=1;
$['myvariable'+i] === $.myvariable1
See: http://www.javascripttoolbox.com/bestpractices/#squarebracket
Matt Kruse
his will do nothing, since you would need "funcname1()" to actually
run the function.
Or preferrably: setTimeout(funcname1,1000);
Matt Kruse
f relative popularity of the different frameworks. There is always
some safety in choosing the "market leader" and if you are going in
blind with no desire to do an in-depth analysis of each option, then
choosing jQuery would probably be your safest best.
IMO,
Matt Kruse
On May 21, 2:
You should post a simple test case, because the simple test case I
created does not show this problem.
Matt Kruse
On May 19, 9:33 am, "asrij...@googlemail.com"
wrote:
> Hi Guys,
>
> just started to upgrade my site jquery version to the latest, now I'm
> facing s
On May 14, 5:17 am, sebastien creme wrote:
> Dynamic colspan setted via style property seems not work on IE.
For some reason, jQuery currently maps rowspan->rowSpan, but not
colspan->colSpan.
http://dev.jquery.com/ticket/4397
Matt Kruse
I've updated my previous cheat sheet to be in line with jQuery 1.3.2.
I think it's more useful than other cheat sheets that simply dump
method names, but hey, that's personal preference ;)
http://www.javascripttoolbox.com/jquery/cheatsheet/
Enjoy
Matt Kruse
d to just a stand-alone constructor
function called jQuery() works fine and would seem cleaner.
Any other questions? :)
Matt Kruse
HOD() because $() creates a
jQuery object, and METHOD is in its prototype object.
Hope that helps,
Matt Kruse
is doing what it does, you need to dig into the
core javascript language to really understand what is going on.
Matt Kruse
javascript, and if you have a good understanding
of the language then reading the source and understanding how it works
will no longer be a challenge.
Matt Kruse
will be shown.
I haven't done much browser testing yet, so this really is an alpha
kind of release.
If you have any feedback, please let me know so I can fancy it up for
it's final release!
Matt Kruse
s for improving .each()
http://groups.google.com/group/jquery-dev/browse_frm/thread/be468dd3344f5f26/d340a8799e416615
Matt Kruse
On Apr 21, 4:09 pm, Karl Swedberg wrote:
> Here you go:
> http://plugins.jquery.com/latest_releases/feed
Cool, is this new, or did I just not find it when I looked?
I'd like to see more items in the feed, too. So it would hopefully
reach back 3-5 days at least.
Matt Kruse
o scraping this: http://plugins.jquery.com/project/Plugins/date
Getting this page as RSS would be fantastic.
Matt Kruse
t do:
$("div[rel]").each(function(){
if (!this.id) this.id = this.rel;
});
Of course, it would probably be better to avoid this altogether and
use the rel attribute to make selections to begin with.
Matt Kruse
a scrolling "window":
http://www.javascripttoolbox.com/lib/floatingheader/
Hope that helps,
Matt Kruse
$tr[0].style.display='none';
else {
$tr[0].style.display='';
}
});
});
Personally, I would also avoid using each(), and avoid the find()
calls by using native DOM methods if this doesn't offer any speed-up.
Matt Kruse
pp or something. As always, the compromise between
performance and other factors is something you have to consider
yourself.
Matt Kruse
roper for your header row
and for your content.
You can email me privately if it still doesn't work after fixing that.
Matt Kruse
On Mar 19, 5:00 pm, bob wrote:
> Well, that did not help much
> So what is the problem then? Why do I get false?
Internally, a jQuery object is an array of references to DOM objects.
Even though two jQuery objects may contain the same references
internally, they are distinct objects, and theref
hange the global x!
})();
})();
alert(x);
Some may consider this to be semantics, but it's important. :)
Matt Kruse
uot;checkbox") {
obj.checked = obj.defaultChecked;
}
...
}
Matt Kruse
ds (".")."
The NAME attribute is CDATA, not ID or NAME.
http://lmgtfy.com/?q=name+attribute+cdata+id+token
;)
Matt Kruse
put name. See any one
of many discussions on the web on this topic.
Matt Kruse
elative'});
$target.parent().addClass("open");
$target.fadeOut(10, function(){
Every time you do $() you are calling a function and creating a new
object, which actually has some overhead. Only jQuery-ize an object
once, and then refer back to that jQuery object repeatedly.
Matt Kruse
who thinks they have a need to check the browser would benefit
from reading more about feature detection and why it is almost always
a better strategy. It just doesn't come naturally at first for many,
and you might struggle through some "yeah, BUT!" moments, but in the
end you'll be better off.
Matt Kruse
t's just a minor quibble anyway. It's similar to lines like this in
the jquery source:
if ( typeof text !== "object" && text != null )
Fixing things like this would tighten and improve the code a bit, IMO.
Matt Kruse
On Feb 18, 6:57 am, John Resig wrote:
> typeof FOO === "string"
> typeof FOO === "number"
> typeof FOO === "boolean"
== is sufficient. typeof always returns a string.
Matt Kruse
IMO, seem to be the weakest link when implemting jQuery, and
it would be great if there were some better models and guidelines for
plugin development that would make the end results better for
everyone.
Matt Kruse
to solve every problem "the jQuery way" is a mistake. Use
it only when it makes things better (which is quite often, for me).
Matt Kruse
On Jan 8, 9:17 am, Eric Garside wrote:
> And, never, ever use inline events.
I disagree. I use them all the time, because it's too slow to attach
them after page load using jQuery, especially on large, complex pages.
Matt Kruse
uestions. It seems
to have been written by someone with very limited javascript
knowledge. The fact that they mistake "closures" for "enclosures" and
call the topic "super-impressive" would cause me to run away
immediately.
Matt Kruse
ssname.
> But the background does not change.
It does for me, both in IE6 and FF3.
And I don't see why it wouldn't change.
How are you testing it?
Matt Kruse
ource that
includes error-checking and warnings built-in as a "developer"
package. But assuming that won't happen, this is a way to "patch in"
this kind of functionality.
Any thoughts?
Matt Kruse
SOURCE:
http://code.jquery.com/jquery-</a>
latest.
izing the CSS is straight-forward
and documented.
There are many examples showing off lots of the functionality here.
The best way to see what this plugin can do is to try it out!
http://www.javascripttoolbox.com/lib/contextmenu/
I hope it is useful to some of you. Feedback is of course appreciated.
e this primary for my own use, but I think that a lot of people
might find it useful.
I welcome any feedback! Thanks!
Matt Kruse
;s a complex selector evaluate it globally, then
check to see if the item to be matched is contained within the
results. This would be slow in some cases, for sure, but would
probably behave as many people expect. It seems like the behavior
of .is() confuses a lot of people when they first use it (myself
included).
Matt Kruse
If you've used jQuery on other pages, then it's very likely that the
js has been cached in the user's browser anyway. Loading it again
should not affect load times in most cases.
Matt Kruse
On Sep 18, 3:50 pm, Alex Weber <[EMAIL PROTECTED]> wrote:
> That's pos
d/y")); // You should do something more
useful than alert!
Hope that helps,
Matt Kruse
jQuery, I think this should work correctly regardless of doctype as
well. IMO :)
Matt
On Sep 17, 5:49 pm, ricardobeat <[EMAIL PROTECTED]> wrote:
> There is a reason it's called "Quirks" mode :)
>
> On Sep 17, 2:26 pm, Matt Kruse <[EMAIL PROTECTED]> wrote:
>
> &
), so that more complex selectors that depend on
hierarchy could be used. I'm not sure what impact this would have on
speed.
Matt Kruse
oogle.com/group/jquery-en/browse_thread/thread/c39f52b6c5d1feac
This is my way of handling event delegation on elements which may have
child elements that get the actual event.
Matt Kruse
called, it returns the internal height,
minus borders and padding.
When height(val) is called, the height includes borders and padding.
I believe these should behave consistently in quirks mode. In
standards mode they work fine.
For now I will write a fix that switches based on compatMode.
Matt Kruse
bubble chain - just against the actual
event target.
For example, I load a table into a container via ajax, and I want to
delegate the handling of table row clicks to the container so it still
works after ajax reloads. The table source may look like:
Matt
Kruse
I want to fire
ecified in a literal.
Matt Kruse
l be a browser that will gain user share at some point, IMO, and
it's better to be ahead of the curve than playing catch-up.
Matt Kruse
to pull it out into another function to avoid so many
nested anonymous functions. I think it's easier to read:
function getClickFunc(i) {
return (function() {
pageClicked(i);
console.log("i:"+i);
});
}
for (var i = 1; i < totalPages + 1; i++) {
$("#pages_panel").append($(" " + i + "")
.click( getClickFunc(i) );
}
(careful, above not tested and is highly subject to typos. But the
concept should be clear)
Matt Kruse
Query functions:
http://www.javascripttoolbox.com/lib/selectbox/jquery.php
Matt Kruse
-ized it yet, but my lib has some advantages over the
link above and could be easily made into a jQuery plugin with a small
amount of effort:
http://www.javascripttoolbox.com/lib/selectbox/
Matt Kruse
ince then in
our dev groups and is what we generally use. I considered releasing
it, but thought that another hack-of-a-hack-of-a-hack plugin would
just add more confusion. :)
Matt Kruse
(){ return "5px"; })());
First, that's not a closure, it's just an immediate execution of an
anonymous function (which can also be used to create a closure).
Second, I can't think of any reason to do that over just using "5px"
as the value :)
Matt Kruse
d practice for all plugins to break their
logic into small pieces for this reason, IMO. With browser scripting,
you can never be certain that you have considered everything a user
may want to do. Making it easier to override specific pieces of logic
is a good thing.
Thanks,
Matt Kruse
.$blocked))
return;
if (!full) el.$blocked = b;
//var $e = full ? $() : $(el).find('a,:input');
//$.each(['mousedown','mouseup','keydown','keypress','click'],
function(i,o) {
//$e[b?'bind':'unbind'](o, $.blockUI.impl.handler);
//});
}
Matt Kruse
blems.
If you're positive you'll get an element back, why not just do:
$('#something')[0].tagName
?
Matt Kruse
ging introduces a noticeable lag in IE.
Matt Kruse
..
> o.filter(function(){return !$(this).parent().is('unwantedclass');});
True, but I'm needing to checking for the class on any element in the
parent chain, not just the immediate parent. So I guess the way I'm
doing it will suffice. Thanks for your help!
Matt Kruse
kings of these methods
- can anyone clarify?
(all my testing is in IE6 only, btw)
My real-world goal is to make sure an element has no parent with a
certain class, and take action only if this is true. I wanted to use
the .is() method above, but I am doing this instead for now:
if (o.parents().filter('div.unwantedclass').size()==0) { ... }
Is there a better way?
Matt Kruse
ng destroyed
when unblocked.
> If you cache it before
> calling blockUI you can use the same element over and over as shown in the
> last example on this page:
Does the example create a memory leak pattern via the circular
reference? I haven't checked it with drip, but it looks to me like a
leak scenario.
Matt Kruse
sure I ever will. I will give the domain to anyone who
builds a working tool similar to what I was thinking of, which it
sounds like you are.
Matt Kruse
r browser coming out that has the same problem but
won't execute the fix because you've limited it to only safari?
Fixing browser-specific bugs using browser sniffing is highly suspect
and almost never necessary. In almost all cases, the bug/quirk can be
fixed in the general case without any check for browser.
Matt Kruse
ecific browser using unnecessary browser
sniffing. Or are there other reasons that I'm not aware of?
Matt Kruse
ay be justified, but surely some of the sniffing that exists in
jQuery already is unnecessary.
Matt Kruse
, I wouldn't be able to built an updated
package and I'd know I couldn't update yet. I'd love to build it if
only I had 2 spare seconds in life ;)
Matt Kruse
er changes). I will
look into it further when I get a chance, but I thought I would post a
message now in case anyone else is having a similar problem.
Of course, it could be my own problem somewhere, but I'll try to rule
that out ;)
Matt Kruse
finds technical errors or
has any suggestions, feel free to email me.
Matt Kruse
7;test')");
for (var i=0; i<10; i++) {
f();
}
compiles it only once, so there is no performance hit. And this would
be the case in the change I suggested.
Matt Kruse
e places. But more of a mental exercise than anything extremely
practical ;)
Matt Kruse
peof
'function'.
There would be no visible effect anywhere else in plugins, etc.
>The cascade of side-effects is enormous.
I don't see any side-effect at all, but I may of course be wrong ;)
Matt Kruse
sure by passing a string, you could always
pass the function ref instead if you needed to.
Matt Kruse
on a regular basis and stays updated with the latest bug
fixes and enhancements.
If anyone thinks this is a good idea and wants to develop this kind of
functionality, I'd be willing to point or transfer the domain to a
site that offers this kind of service.
Matt Kruse
han reading the docs and eventually
finding that .is() is the correct way to do it. It makes jQuery a
little more approachable and user-friendly if it has exactly what
you're looking for and expect, even though it may just be a wrapper
for the real underlying functionality.
Matt Kruse
gins will only increase. And since
most users will need to use plugins, the "look and feel/API" of jQuery
to them will in large part be that of the plugins they choose, which
leaves jQuery's fate up to random developers creating random plugins.
Not so good, IMO.
Matt Kruse
strips much of
> it's purpose.
CSS Specificity is a big reason to use id's. You can make a rule using
#id { ... }
and know that it will take precedence over all your tag/class-based
rules.
Matt Kruse
version so as to be browser-agnostic?
3) Is there any documentation about what @tags are supported?
4) Is it extensible for use with my own custom @tags ?
Thanks!
Matt Kruse
method that does its null checks
and each'ing or whatever and then calls this underlying method on the
object's className attribute directly.
Is there any reason why it's not done this way? Perhaps there are
things I'm not thinking of :)
Matt Kruse
e extra bytes to make it work correctly, but IMO it is worth
it.
Matt Kruse
fic fashion, build a page to exploit that, then have
you visit his page AFTER you have already logged in and established a
session on the other site.
In other words, that's not going to happen. IMO.
Matt Kruse
On Apr 14, 12:42 pm, "Daemach" <[EMAIL PROTECTED]> wrote:
> IE doesn't seem to like to eval anonymous functions. Is there a way
> around this other than to strip the function wrapper?
> eval("function(){alert('iesucks')}")()
Why not this instead
One approach would be to put connected rows in separate tbody tags,
then sort the tbody objects based on the first tr in the tbody.
This would be a specialized way of sorting, though, and you would
probably need to write some custom code to accomplish it.
Matt Kruse
On Apr 13, 12:53 pm, "
tag may also be display:none which
would cause it to be hidden as well, and those tags are not parents of
the cell itself. Checking the cell's current 'display' value will of
course get me nowhere.
I've begun writing logic to handle this case, but it would be great if
someone has already done it!
Matt Kruse
I am trying to finish up my table sorting/paging/filtering plugin
here:
http://www.JavascriptToolbox.com/lib/table/
(been trying to finish it up for a while... sick kids don't mix well
with javascript development free time...)
It works fine with sorting, filtering, and paging all on the same
tabl
97 matches
Mail list logo