[jquery-dev] Re: possible event bug when binding to content added with html()?

2009-07-07 Thread Ralph Whitbeck
Have you tried using live instead of bind?

http://docs.jquery.com/Events/live#typefn


On Tue, Jul 7, 2009 at 9:15 PM, Dennis Jacobfeuerborn <
djacobfeuerb...@gmail.com> wrote:

>
> http://pastebin.com/f6990228d
>
> In this code clicking on the text should change it between "STATE1"
> and "STATE2" but doesn't. It actually does switch to STATE1 again but
> due to a spurious "click" event immediately switches back to STATE2 so
> that the switch can't be really seen. Uncommenting the commented
> javascript line and commenting the one above it no longer uses html()
> and show the correct behavior.
>
> Is this a bug or am I doing something fundamentally wrong here?
>
> Regards,
>  Dennis
>
> PS: I filed a bug here: http://dev.jquery.com/ticket/4867
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] possible event bug when binding to content added with html()?

2009-07-07 Thread Dennis Jacobfeuerborn

http://pastebin.com/f6990228d

In this code clicking on the text should change it between "STATE1"
and "STATE2" but doesn't. It actually does switch to STATE1 again but
due to a spurious "click" event immediately switches back to STATE2 so
that the switch can't be really seen. Uncommenting the commented
javascript line and commenting the one above it no longer uses html()
and show the correct behavior.

Is this a bug or am I doing something fundamentally wrong here?

Regards,
  Dennis

PS: I filed a bug here: http://dev.jquery.com/ticket/4867

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] Re: Locale support in jquery

2009-07-07 Thread Ant

Its about 50/50 according to the ones on my machine anyway

so...
var fullStopCultures = ["", "ar-sa", "zh-tw", "en-us", "he-
il", "ja-jp", "ko-kr", "th-th", "ur-pk", "fa-ir", "hy-am", "af-za",
"hi-in", "sw-ke", "pa-in", "gu-in", "ta-in", "te-in", "kn-in", "mr-
in", "sa-in", "kok-in", "syr-sy", "dv-mv", "ar-iq", "zh-cn", "de-ch",
"en-gb", "es-mx", "it-ch", "ar-eg", "zh-hk", "en-au", "ar-ly", "zh-
sg", "en-ca", "es-gt", "fr-ch", "ar-dz", "zh-mo", "de-li", "en-nz",
"ar-ma", "en-ie", "es-pa", "ar-tn", "en-za", "es-do", "ar-om", "en-
jm", "ar-ye", "en-029", "ar-sy", "en-bz", "es-pe", "ar-jo", "en-tt",
"ar-lb", "en-zw", "ar-kw", "en-ph", "ar-ae", "ar-bh", "ar-qa", "es-
sv", "es-hn", "es-ni", "es-pr", "bn-bd", "en-sg", "en-my", "mn-mong-
cn", "qut-gt", "rm-ch", "mi-nz", "ug-cn", "moh-ca", "ga-ie", "ii-cn",
"quz-pe", "ig-ng", "nso-za", "yo-ng", "ha-latn-ng", "fil-ph", "ne-np",
"am-et", "iu-cans-ca", "si-lk", "lo-la", "km-kh", "cy-gb", "bo-cn",
"as-in", "ml-in", "or-in", "bn-in", "en-in", "es-us", "mt-mt", "zu-
za", "xh-za", "tn-za", "iu-latn-ca"];
function numberLocale(value, locale) {
return Number(value.replace(fullStopCultures.indexOf
((locale || navigator.language || navigator.userLanguage).toLowerCase
()) > -1 ? /[^0-9\.]/ : /[^0-9,]/, ""));
}

This i will remove everything but the decimal marker according to the
locale passed or the one your browser is set to.
Changing the language list in your browser does not work in this case
as navigator.language || navigator.userLanguage pick up the accepted
languages.
So to support the accepted languages, I'm going for a server-side
solution which is a shame, but there we go.

Ant

On Jul 6, 9:21 pm, Már  wrote:
> On Jul 6, 7:10 pm, "Anthony Johnston" 
> wrote:
>
> > 1.200,45 is a valid number format for some locales
>
> Actually, it's a valid format for lots and lots! of locales. :-)
> 1 200,45 and 1'200,45 are also fairly common formats.
>
> --
> Már
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] Re: Status of $.browser

2009-07-07 Thread Andrea Giammarchi
... and you do not know how to reuse functions ... Daniel, dunno why this
answer, setTimeout works "like that" before you started to write javascript,
it has always been like that, only IE and some Opera did not get it.

function myReusableFunction(arg1, arg2){
// do your stuff, reuse the function if necessary, avoid useless
closures and redundant code
};

setTimeout(myReusableFunction, 1000, "a", {b:"c"});

Tell me a single reason I should write every time a new function, slower,
with a new closure, slower, to call an already defined function.


setTimeout(function(){
myReusableFunction("a", {b:"c"})
}, 1000);

Now, rather than this, think about setInterval, and make your knowledge
about ECMAScript deeper.

Thanks



On Tue, Jul 7, 2009 at 5:41 PM, Daniel Friesen wrote:

>
> As for setTimeout, it has no need for extra arguments. If you think you
> need extra arguments to setTimeout, then you don't know how to use one
> of JavaScript's core features, closures.
>
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] Re: Status of $.browser

2009-07-07 Thread Daniel Friesen

Conditional comments are a far better way to test for IE than 
$.browser.msie is, and those alternate .css rules would be best in an 
ie.css included via conditional comments.

As for setTimeout, it has no need for extra arguments. If you think you 
need extra arguments to setTimeout, then you don't know how to use one 
of JavaScript's core features, closures.

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]

Andrea Giammarchi wrote:
> I think a generic $.browser.IE could always be useful ... sometimes we 
> have to deal with "pixel perfection" and I cannot imagine how many 
> features detections we should do to understand if a table should be 
> 360px rather than 358px cause of duplicated css padding rule ... what 
> I mean is that feature detection are not always possible.
>
> Most simple example? redefine setTimeout making it accept extra 
> arguments as well. If you test this via timeout every sync script in 
> the meanwhile could have get it wrong.
>
> I hope you got my point ( and I do not thing we will all agree into a 
> delayed timed execution environment, do we? )
>
> Regards
>
> On Mon, Jul 6, 2009 at 5:47 PM, Ralph Whitbeck 
> mailto:ralph.whitb...@gmail.com>> wrote:
>
> Rick, from what I understand the reason we singled out Safari was
> we were having an issue with fadeIn, here is the code I found in
> subversion:
>
> if ($.browser.safari) {
> // Safari fadeIn fix- just display it straight.
>
>
> $("#components a.SingleImage" + currentPage + 
> "_plcSideContent1").css("display", "inline");
> }
> else {
> $("#components a.SingleImage" + currentPage + 
> "_plcSideContent1").fadeIn("fast");
>
>
> }
> 
>
> I'll have to get more info if you need it from the developer that
> posted it when he get's back from lunch.
>
> Thanks,
> Ralph
>
>
> On Mon, Jul 6, 2009 at 12:42 PM, Rick Waldron
> mailto:waldron.r...@gmail.com>> wrote:
>
> Ralph,
>
> I'm just sort of curious... could you post up the
> $.browser.safari scenario (explanation of goal as well as code
> used to reach said goal)?
>
> A little curious to see what was trying to be achieved.
>
> Rick
>
>
>
>
>
>
>
> On Mon, Jul 6, 2009 at 12:16 PM, Ralph Whitbeck
> mailto:ralph.whitb...@gmail.com>>
> wrote:
>
> John,
>
> From my experience, I clicked on those guides in the docs
> and I felt overwhelmed with information when I was looking
> for a quick solution to my problem.  Just my two cents. 
>
> As per the SO discussion I just wanted to highlight the
> comments mostly where developers say it's deprecated don't
> use it and the other developers asking then what to do
> instead.
>
> Thanks,
> Ralph
>
>
> On Mon, Jul 6, 2009 at 12:02 PM, John Resig
> mailto:jere...@gmail.com>> wrote:
>
>
> Re-wording the documentation from 'deprecated' to
> 'strongly discourage
> the use of' (or something similar) might be ok. I'm
> not sure what else
> we can do on our end - we already link to a number of
> guides that
> provide good information on the subject matter.
>
> As to the linked Stack Overflow discussion - perhaps
> injecting a rule
> into the stylesheet and then detecting to see if the
> rule sticks might
> work (not sure, just guessing off-hand).
>
> --John
>
>
>
> On Mon, Jul 6, 2009 at 11:53 AM, Ralph
> Whitbeck > wrote:
> > As of 1.3 $.browser is listed as deprecated in
> support of jQuery.support.
> > The thinking is that developers should be basing
> their checks on
> > functionality instead of user agent strings.
> >
> > I think this is throwing a lot of novice jQuery
> users as they see the word
> > deprecated and think that they shouldn't use it as
> the method is going
> > away.  From my understanding that method isn't going
> away.
> > (http://osdir.com/ml/misc/2009-01/msg1.html
> "According to John R,
> > $.browser and version will remain in the core
> indefinitely, despite being
> > deprecated...")  For some cases it's really
> difficult to determine what
> > piece of functionality to use to get the desired
> result.  For instance,
> > today, I noticed a coworker used $.browser.safar

[jquery-dev] Re: Status of $.browser

2009-07-07 Thread Andrea Giammarchi
I think a generic $.browser.IE could always be useful ... sometimes we have
to deal with "pixel perfection" and I cannot imagine how many features
detections we should do to understand if a table should be 360px rather than
358px cause of duplicated css padding rule ... what I mean is that feature
detection are not always possible.

Most simple example? redefine setTimeout making it accept extra arguments as
well. If you test this via timeout every sync script in the meanwhile could
have get it wrong.

I hope you got my point ( and I do not thing we will all agree into a
delayed timed execution environment, do we? )

Regards

On Mon, Jul 6, 2009 at 5:47 PM, Ralph Whitbeck wrote:

> Rick, from what I understand the reason we singled out Safari was we were
> having an issue with fadeIn, here is the code I found in subversion:
>
> if ($.browser.safari) {
> // Safari fadeIn fix- just display it straight.
>
> $("#components a.SingleImage" + currentPage + 
> "_plcSideContent1").css("display", "inline");
> }
> else {
> $("#components a.SingleImage" + currentPage + 
> "_plcSideContent1").fadeIn("fast");
>
> }
>
> I'll have to get more info if you need it from the developer that posted it
> when he get's back from lunch.
>
> Thanks,
> Ralph
>
>
> On Mon, Jul 6, 2009 at 12:42 PM, Rick Waldron wrote:
>
>> Ralph,
>>
>> I'm just sort of curious... could you post up the $.browser.safari
>> scenario (explanation of goal as well as code used to reach said goal)?
>>
>> A little curious to see what was trying to be achieved.
>>
>> Rick
>>
>>
>>
>>
>>
>>
>>
>> On Mon, Jul 6, 2009 at 12:16 PM, Ralph Whitbeck > > wrote:
>>
>>> John,
>>>
>>> From my experience, I clicked on those guides in the docs and I felt
>>> overwhelmed with information when I was looking for a quick solution to my
>>> problem.  Just my two cents.
>>>
>>> As per the SO discussion I just wanted to highlight the comments mostly
>>> where developers say it's deprecated don't use it and the other developers
>>> asking then what to do instead.
>>>
>>> Thanks,
>>> Ralph
>>>
>>>
>>> On Mon, Jul 6, 2009 at 12:02 PM, John Resig  wrote:
>>>

 Re-wording the documentation from 'deprecated' to 'strongly discourage
 the use of' (or something similar) might be ok. I'm not sure what else
 we can do on our end - we already link to a number of guides that
 provide good information on the subject matter.

 As to the linked Stack Overflow discussion - perhaps injecting a rule
 into the stylesheet and then detecting to see if the rule sticks might
 work (not sure, just guessing off-hand).

 --John



 On Mon, Jul 6, 2009 at 11:53 AM, Ralph Whitbeck<
 ralph.whitb...@gmail.com> wrote:
 > As of 1.3 $.browser is listed as deprecated in support of
 jQuery.support.
 > The thinking is that developers should be basing their checks on
 > functionality instead of user agent strings.
 >
 > I think this is throwing a lot of novice jQuery users as they see the
 word
 > deprecated and think that they shouldn't use it as the method is going
 > away.  From my understanding that method isn't going away.
 > (http://osdir.com/ml/misc/2009-01/msg1.html "According to John R,
 > $.browser and version will remain in the core indefinitely, despite
 being
 > deprecated...")  For some cases it's really difficult to determine
 what
 > piece of functionality to use to get the desired result.  For
 instance,
 > today, I noticed a coworker used $.browser.safari to build code
 specific to
 > a Safari issue we were having.  Knowing that $.browser was listed as
 > deprecated I went to find the correct way to segment out safari using
 > $.support() unfortunately based on the docs I found this to be
 impossible to
 > easily determine which is the best approach to use and I am still not
 sure
 > it's possible.
 >
 > I did some research to see if there was an easy way to segment Safari
 from
 > the rest using $.support() and found this thread on Stack Overflow
 that
 > seems to support developer confusion on the issue.
 >
 http://stackoverflow.com/questions/584285/detecting-ie6-using-jquery-support
 >
 > Developers want to do the right thing and listing the method as
 deprecated
 > flags the developer to avoid that method at all costs.  I think it
 would be
 > better to list the method as not a "best practice" instead of
 deprecated and
 > explain why functionality checks are better then user agent sniffing.
 >
 > Also it would be good to flush out some scenarios for developers to
 use
 > which functionality test for certain browsers and certain scenarios.
 >
 > Thoughts? Am I off base on this?
 >
 > Ralph
 >
 >
 >
 > >
 >



>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~-~--~~---

[jquery-dev] Re: bindReady on Safari when dynamically loaded ...

2009-07-07 Thread Andrea Giammarchi
Sorry but if there is no jQuery how can you add these callbacks to the
jQuery internal list?

the classic function is:



onload = function(){

// call external file
load("jquery-1.3.2.js").And(function(){
// do stuff
alert(jQuery);
});
};



function load(src){
function onload(){
script.onload = script.onreadystatechange = function(){};
script.parentNode.removeChild(script);
script = null;
if(callback)
callback();
};
var script  = document.createElement("script"),
callback
;
script.type="text/javascript";
script.src=src;
script.onload = onload;
script.onreadystatechange = function(){
if(/complete/i.test(script.readyState))
onload();
};

(document.getElementsByTagName("head")[0]||document.documentElement).appendChild(script);
return {And:function($callback){
callback = $callback;
}};
};


Regards

On Thu, Jul 2, 2009 at 11:30 AM, Ricardo  wrote:

>
> You can call jQuery.ready() to fire all the queued functions.
>
> On Jun 30, 9:49 pm, Steven Parkes  wrote:
> > I dynamically load jquery into my page and the change that happened at/
> > round Ticket 2614 (http://dev.jquery.com/ticket/2614) / rev 5970 (or,
> > in other words, between 1.2.6 and 1.3.2) had, at least for me, a
> > pretty adverse effect.
> >
> > Looks like now if jquery is ever loaded after the doc readystate is
> > loaded/complete, jquery is never going to be ready. Looks like ticket
> > was to clean up the CSS stuff, but was this other behavior change
> > intentional? I'd really like to be able to load jquery dynamically and
> > that seems impossible for me at the moment on Safari.
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] Re: Join several JS scripts into one big file to lower http request

2009-07-07 Thread Andrea Giammarchi
give it a try, once you have Java Runtime Environment you can simply
configure one or more batch files and create the optimized version in a
click.

Then the best way to serve it is via pre compressed gzip/deflate and decide
via server if the browser accept which version and serve it.

Specially with big files this practice is suggested rather than
ob_start('ob_gzhandler') et similar, simply because compression could be
expensive for the server.

I had a project called MyMin which aims was to do it, but the service did
not grab enough attention so I created a batch file and I let you manage the
rest:

http://www.3site.eu/yuibompressor/

Known bug right now are with special chars in the first line, I am using a
Python 3000 parser but I am thinking to create a better manager entirely via
C so both Linux and Windows shell could call the file and that's it. Stay
tuned?

Regards

2009/7/4 Damir Zekić 

>
> On Jul 4, 12:41 am, Samer  wrote:
> > I found it tricky to use an automated combiner thingy in that it
> > doesn't know the order of the javascripts to be added to the page.
>
> I use Sprockets[1] to combine multiple scripts into one file. With
> sprockets you write "require" statements and it automatically manages
> the dependencies for you so that the same file is not included
> multiple times. For example:
>
> //= require 
> //= require "other_script_file
> $(...);
>
> [1] http://github.com/sstephenson/sprockets/tree/master
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~--~~~~--~~--~--~---



[jquery-dev] Re: IE6 memory leak

2009-07-07 Thread pob

I think I found a temporary fix for the problem...just
calling .datepicker('destroy') on the unload event works for me:


$(window).bind("unload", function() {
  $('.hasDatepicker').datepicker('destroy');
  $(window).unbind();
});


- Pob


On Jul 3, 1:48 pm, pob  wrote:
> I care about this problem too, and can't find a way of fixing it.
> Please somebody fix it For the moment I'll go to Kevin Lucks
> version...doesn't look as nice but doesn't leak either!!
>
> On Jul 1, 7:25 pm, "jquery.redsqu...@googlemail.com"
>
>  wrote:
> > Anybody else care about the above issues?
>
> > On Jun 30, 6:55 pm, "jquery.redsqu...@googlemail.com"
>
> >  wrote:
> > > It happened using ie also and monitoring in task manager/perfmon
>
> > > On Jun 30, 5:41 pm, mharen  wrote:
>
> > > > I'm not sure drip is a good tool for this job. This page:
>
> > > >http://jsbin.com/eyuri
>
> > > > Shows a leak, too, even though I don't even have a ready() event. All
> > > > it does is include jq/jq-ui.
>
> > > >http://www.picvault.info/images/537090310_eyuri.png
>
> > > > Reloading it in IE6 does *not* show a leak in *this* case. The other
> > > > tests are still leaking.
>
> > > > On Jun 30, 11:59 am, mharen  wrote:
>
> > > > > I'm glad that you're able to reproduce some of the behavior (edited or
> > > > > otherwise)--I'm not going crazy!
>
> > > > > I've read that removing elements makes the problem worse and that
> > > > > setting the .html to "" is better. I think .empty() does that. I
> > > > > wonder what happens if you try it with .empty()?
>
> > > > > On Jun 30, 11:53 am, "jquery.redsqu...@googlemail.com"
>
> > > > >  wrote:
> > > > > > I have maybe spotted another issue but more jquery related.
> > > > > > Whilst playing with your demo page i tried the following, basically
> > > > > > only adding the remove to the datepicker before reloading.
>
> > > > > >   function CheckForRefresh(){
> > > > > >                                 
> > > > > > if($('#AutoRefresh').attr('checked')){
> > > > > >                                        
> > > > > > $('.DatePicker:enabled').remove
> > > > > > ();
> > > > > >                                         window.location.reload();
> > > > > >                                 }
> > > > > >                         }
>
> > > > > > Look at the drip results for this.very 
> > > > > > worryinghttp://gyazo.com/86d71136e950d1e88e953b8d1e5b71ed.png
>
> > > > > > On Jun 30, 3:53 pm, mharen  wrote:
>
> > > > > > > You're using sp3--which seems to be fixed. Can anyone verify this
> > > > > > > problem with IE6-sans-sp or perhaps with sp1?
>
> > > > > > > Here's drip on my machine, using a now-public 
> > > > > > > pagehttp://jsbin.com/omoya
>
> > > > > > >http://www.picvault.info/images/537090308_omoya.png
>
> > > > > > > On Jun 30, 10:12 am, "jquery.redsqu...@googlemail.com"
>
> > > > > > >  wrote:
> > > > > > > > Sorry should have included that info also, see 
> > > > > > > > herehttp://gyazo.com/e4ec10e5ae13df428349c1b8f567214d.png.
>
> > > > > > > > Cheers
>
> > > > > > > > On Jun 30, 2:54 pm, mharen  wrote:
>
> > > > > > > > > What version of IE6 are you using? I've heard reports that 
> > > > > > > > > this has
> > > > > > > > > been fixed in IEsp2 and possibly IEsp1. This is repeatable 
> > > > > > > > > for me in
> > > > > > > > > IE-sans-sp and IEsp1.
>
> > > > > > > > >http://stackoverflow.com/questions/1051090/how-can-i-control-ie6jquer...
>
> > > > > > > > > Thanks,
> > > > > > > > > Michael Haren
>
> > > > > > > > > On Jun 30, 8:01 am, "jquery.redsqu...@googlemail.com"
>
> > > > > > > > >  wrote:
> > > > > > > > > > I am not able to reproduce this, see the following drip leak
> > > > > > > > > > screengrab.http://gyazo.com/579a64dc877016ae6d079228fc863728.png
>
> > > > > > > > > > Although memory increases quickly to begin with the gc 
> > > > > > > > > > seems to kick
> > > > > > > > > > in at regular intervals leaving a relatively stable 
> > > > > > > > > > footprint. That
> > > > > > > > > > seems fine to me considering the amount of reloads that 
> > > > > > > > > > occured during
> > > > > > > > > > the test will be way and above over any normal site usage.
>
> > > > > > > > > > On Jun 29, 9:10 pm, mharen  wrote:
>
> > > > > > > > > > > I filed a ticket for this with the repro as a file 
> > > > > > > > > > > attachment (http://
> > > > > > > > > > > dev.jqueryui.com/ticket/4644). Sorry if posting here and 
> > > > > > > > > > > there is a no-
> > > > > > > > > > > no.
>
> > > > > > > > > > > On Jun 29, 3:35 pm, mharen  wrote:
>
> > > > > > > > > > > > First off: thanks for jquery. I love it. Second: I'm 
> > > > > > > > > > > > running into an
> > > > > > > > > > > > IE6 memory leak. Here's a repro:
>
> > > > > > > > > > > > begin
> > > > > > > > > > > >          > > > > > > > > > > > Transitional//EN"
> > > > > > > > > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> > > > > > > > > > > >         http://www.w3.org/1999/xhtml"; >
> > > > > > > > > > > >