[jquery-dev] Re: new $
... If a user uses new $ this user simply does not truly understand/ know JavaScript but fortunately will not harm anybody... No it wont, unless this user is a team leader and starts blaming jQuery on everything. And this happens much more than anyone here (it seems) realises. But. This is another subject. PS: jQuery.fast = false ; jQuery.error_code = 0xABCD ; function(selector, context) { if ( ! jQuery.fast) if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); } On May 14, 2:59 pm, Andrea Giammarchi andrea.giammar...@gmail.com wrote: to do that you need to change the contructor: function(selector, context) { if(this instanceof jQuery) throw new Error(Can not new $()); return new jQuery.fn.init(selector, context); } this means an extra if for each jQuery call, something not that welcome for performances reason. At the same time, jQuery itself relies in this JavaScript peculiarity, so I would not create conflicts between jQuery developers and users. If a user uses new $ this user simply does not truly understand/know JavaScript but fortunately will not harm anybody. On Thu, May 14, 2009 at 10:23 AM, DBJDBJ dbj...@gmail.com wrote: Ah, new $, is possible and therefore not barred ... Left in there as a sort of a land-mine for the newcomers ? Or as an esoteric test for GC developers ? Highly useless it seems to me. Back to reality and jQuery. $ is defined as: function(selector, context) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init(selector, context); } Maybe I am just searching for ECMA harmony, but will $() definition that throws an exception if new-ed , be usefull : try { new $ ; } catch ( x ) { // x. message == Can not new $() } Au-contraire : will this hurt anyone ? Is exception throwing porgramming idiom damaging for jQuery? --DBJ PS: if Python was choosen as a Netscape scripting language, World would be a better place ... If nothing else its name is less ridiculous ... ;o) On May 14, 9:04 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: it's called JavaScript :D jokes a part, every function is a constructor as well so new function is always valid. If the function returns an object, it does not matter which new is because it will be an instance of returned object one. if it is a primitive it will simply be lost: var a = new function(){return 123;}; // a is an instance of anonymous function this allows us to create Python like initializations: function PythonLike(){ return this instanceof arguments.callee ? this : new arguments.callee; }; alert(PythonLike() instanceof PythonLike); alert(new PythonLike() instanceof PythonLike); true in both cases jQuery returns a new jQuery.prototype.init where init method shares the same prototype ... better now? :-) On Wed, May 13, 2009 at 11:57 PM, DBJDBJ dbj...@gmail.com wrote: Why is this allowed : var jq = new $ ; Does it matter? -- DBJ --~--~-~--~~~---~--~~ 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: new $
;) I still see an if statement there, heh. I prefer the conditional comments + build system approach. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] DBJDBJ wrote: ... If a user uses new $ this user simply does not truly understand/ know JavaScript but fortunately will not harm anybody... No it wont, unless this user is a team leader and starts blaming jQuery on everything. And this happens much more than anyone here (it seems) realises. But. This is another subject. PS: jQuery.fast = false ; jQuery.error_code = 0xABCD ; function(selector, context) { if ( ! jQuery.fast) if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); } On May 14, 2:59 pm, Andrea Giammarchi andrea.giammar...@gmail.com wrote: to do that you need to change the contructor: function(selector, context) { if(this instanceof jQuery) throw new Error(Can not new $()); return new jQuery.fn.init(selector, context); } this means an extra if for each jQuery call, something not that welcome for performances reason. At the same time, jQuery itself relies in this JavaScript peculiarity, so I would not create conflicts between jQuery developers and users. If a user uses new $ this user simply does not truly understand/know JavaScript but fortunately will not harm anybody. On Thu, May 14, 2009 at 10:23 AM, DBJDBJ dbj...@gmail.com wrote: Ah, new $, is possible and therefore not barred ... Left in there as a sort of a land-mine for the newcomers ? Or as an esoteric test for GC developers ? Highly useless it seems to me. Back to reality and jQuery. $ is defined as: function(selector, context) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init(selector, context); } Maybe I am just searching for ECMA harmony, but will $() definition that throws an exception if new-ed , be usefull : try { new $ ; } catch ( x ) { // x. message == Can not new $() } Au-contraire : will this hurt anyone ? Is exception throwing porgramming idiom damaging for jQuery? --DBJ PS: if Python was choosen as a Netscape scripting language, World would be a better place ... If nothing else its name is less ridiculous ... ;o) On May 14, 9:04 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: it's called JavaScript :D jokes a part, every function is a constructor as well so new function is always valid. If the function returns an object, it does not matter which new is because it will be an instance of returned object one. if it is a primitive it will simply be lost: var a = new function(){return 123;}; // a is an instance of anonymous function this allows us to create Python like initializations: function PythonLike(){ return this instanceof arguments.callee ? this : new arguments.callee; }; alert(PythonLike() instanceof PythonLike); alert(new PythonLike() instanceof PythonLike); true in both cases jQuery returns a new jQuery.prototype.init where init method shares the same prototype ... better now? :-) On Wed, May 13, 2009 at 11:57 PM, DBJDBJ dbj...@gmail.com wrote: Why is this allowed : var jq = new $ ; Does it matter? -- DBJ --~--~-~--~~~---~--~~ 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: new $
Tell your head of whatever that a title in a contract does not necessary mean extraordinary skills and if he would like to improve his JavaScript knowledge he is more than welcome in this ml ( probably more as reader ... ) anyway ... function init(selector, context){ if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); }; function jQuery(selector, context) { return jQuery.fast ? new jQuery.fn.init(selector, context) : init.call(this, selector, context) ; }; Conditional is a bit faster than an if but still it is something that does not make sense because as I said the nature of the jQuery callback is dual ( both function/constructor ... it does not matter which way you call it, the result will always be an instance of jQuery, if you like weist time writing an alread implicit new everywhere, it cannot be a jQuery issue, do you agree? ) On Fri, May 15, 2009 at 10:20 AM, Daniel Friesen nadir.seen.f...@gmail.comwrote: ;) I still see an if statement there, heh. I prefer the conditional comments + build system approach. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] DBJDBJ wrote: ... If a user uses new $ this user simply does not truly understand/ know JavaScript but fortunately will not harm anybody... No it wont, unless this user is a team leader and starts blaming jQuery on everything. And this happens much more than anyone here (it seems) realises. But. This is another subject. PS: jQuery.fast = false ; jQuery.error_code = 0xABCD ; function(selector, context) { if ( ! jQuery.fast) if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); } On May 14, 2:59 pm, Andrea Giammarchi andrea.giammar...@gmail.com wrote: to do that you need to change the contructor: function(selector, context) { if(this instanceof jQuery) throw new Error(Can not new $()); return new jQuery.fn.init(selector, context); } this means an extra if for each jQuery call, something not that welcome for performances reason. At the same time, jQuery itself relies in this JavaScript peculiarity, so I would not create conflicts between jQuery developers and users. If a user uses new $ this user simply does not truly understand/know JavaScript but fortunately will not harm anybody. On Thu, May 14, 2009 at 10:23 AM, DBJDBJ dbj...@gmail.com wrote: Ah, new $, is possible and therefore not barred ... Left in there as a sort of a land-mine for the newcomers ? Or as an esoteric test for GC developers ? Highly useless it seems to me. Back to reality and jQuery. $ is defined as: function(selector, context) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init(selector, context); } Maybe I am just searching for ECMA harmony, but will $() definition that throws an exception if new-ed , be usefull : try { new $ ; } catch ( x ) { // x. message == Can not new $() } Au-contraire : will this hurt anyone ? Is exception throwing porgramming idiom damaging for jQuery? --DBJ PS: if Python was choosen as a Netscape scripting language, World would be a better place ... If nothing else its name is less ridiculous ... ;o) On May 14, 9:04 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: it's called JavaScript :D jokes a part, every function is a constructor as well so new function is always valid. If the function returns an object, it does not matter which new is because it will be an instance of returned object one. if it is a primitive it will simply be lost: var a = new function(){return 123;}; // a is an instance of anonymous function this allows us to create Python like initializations: function PythonLike(){ return this instanceof arguments.callee ? this : new arguments.callee; }; alert(PythonLike() instanceof PythonLike); alert(new PythonLike() instanceof PythonLike); true in both cases jQuery returns a new jQuery.prototype.init where init method shares the same prototype ... better now? :-) On Wed, May 13, 2009 at 11:57 PM, DBJDBJ dbj...@gmail.com wrote: Why is this allowed : var jq = new $ ; Does it matter? -- DBJ --~--~-~--~~~---~--~~ 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: jQuery.ajax cross domain request with script
On May 14, 7:13 pm, hj2aj jianyi.huan...@gmail.com wrote: Hi there, I am having a problem with the cross domain issue that AJAX has. According to jQuery.ajax documentation, it should handle cross domain request with script and jsonp as data type. However, I cannot manage to get the following works: There is no error according to FireBug, all alerts were executed except the ones in 'success' and 'error' functions. The above example is very similar to something in Ubiquity developed by Mozilla, it works even with dataType: text, but in the 'success' function, it passed down a parameter and eval it. (I wonder whether in Mozilla it has a proxy to handle such request) jQuery.getScript() can handle cross domain request for sure, and it is based on jQuery.ajax with hardcoded dataType: script, however, I still want to have the request made on jQuery.ajax because it provides more controls. Can anyone please let me know why my example does not work, thanks!! jQuery adds a query string to the URL to avoid caching by default, like http://j.maxmind.com/app/geoip.js?_=1242383380394. As you can see that results in a blank page. Add cache: true to the ajax options and it should be fine. cheers -- ricardo --~--~-~--~~~---~--~~ 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: running qunit in envjs
or better yet, why not just delegate to 'console' if globally available: QUnit.log = (consoleconsole.log)? function(result, msg){console.log('['+!!result+'] '+msg);}: function(result, msg){}; then we still have a global hook to logging while keeping it inside the QUnit namespace internally. On Tue, May 12, 2009 at 10:59 PM, chris thatcher thatcher.christop...@gmail.com wrote: I noticed we where using an older testrunner.js with envjs even when running 1.3.2 unit tests. i start playing with it and realized qunit works great and i can even use QUnit.done to output a static html file with the result of running the tests in envjs. the only snag I had was being able to hook to QUnit.log . this may be a bug with envjs implementation of onload so please feel free to point out if im mistaken. here is the script that initiates it: load(build/runtest/env.js); (function($env){ //let it load the script from the html $env.scriptTypes = { text/javascript :true }; var count = 0; window.onload = function(){ //this doesnt work because onload isn't called until after the tests run QUnit.log = function(result, message){ $env.log('('+(count++)+')['+((!!result)?'PASS':'FAIL')+'] ' + message ); }; //this works because done is called from syncronize() QUnit.done = function(pass, fail){ //write resulting window less scripts to an html file jQuery('script').each(function(){ this.type = 'text/envjs'; }); $env.writeToFile( document.documentElement.xml, $env.location('jqenv.html') ); }; }; window.location = test/index.html; })(__env__); I was wondering if you could either add a synchronized 'begin' or let log just be global $.extend(window, { ///... log: log?log:function(result, message); }); thanks thatcher -- Christopher Thatcher -- Christopher Thatcher --~--~-~--~~~---~--~~ 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: Selectors in Live Method
@Zach - Chaining is very powerful, I like the existing functionality as is. There are performance issues like you mention, but I haven't run into a selector on a page that has caused me difficulty yet. *fingers crossed*. If I did, I would either just roll my own by putting the click event on the document and testing for a match to a selector or create a plugin doing what you suggest. Having both in the core might just create confusion, $.live(selector, 'click', function () { }); vs. $(selector).live('click', function () { }); And the latter is more 'jQuery-ish', at least in my mind. On May 12, 9:49 pm, Jed Schmidt t...@nslator.jp wrote: I'm not convinced you're sacrificing that much performance. One of the great things about .live() is that it can be called before the DOM is even ready. The lack of nodes to search means that selection should return almost immediately. Jed Schmidt On May 12, 9:31 am, Zach Leatherman zachleather...@gmail.com wrote: Sure, but you're sacrificing quite a bit in performance to get chaining. I think it would be helpful to have an alternative option, so that devs are aware of the tradeoff (I'm not asking to change $.fn.live), and my suggestion was to use $.live. --~--~-~--~~~---~--~~ 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: running qunit in envjs
I'm confused - why are you attaching the QUnit.done/log handlers inside window.onload? Ideally they should be the very first thing done (after loading the test suite itself). --John On Tue, May 12, 2009 at 10:59 PM, chris thatcher thatcher.christop...@gmail.com wrote: I noticed we where using an older testrunner.js with envjs even when running 1.3.2 unit tests. i start playing with it and realized qunit works great and i can even use QUnit.done to output a static html file with the result of running the tests in envjs. the only snag I had was being able to hook to QUnit.log . this may be a bug with envjs implementation of onload so please feel free to point out if im mistaken. here is the script that initiates it: load(build/runtest/env.js); (function($env){ //let it load the script from the html $env.scriptTypes = { text/javascript :true }; var count = 0; window.onload = function(){ //this doesnt work because onload isn't called until after the tests run QUnit.log = function(result, message){ $env.log('('+(count++)+')['+((!!result)?'PASS':'FAIL')+'] ' + message ); }; //this works because done is called from syncronize() QUnit.done = function(pass, fail){ //write resulting window less scripts to an html file jQuery('script').each(function(){ this.type = 'text/envjs'; }); $env.writeToFile( document.documentElement.xml, $env.location('jqenv.html') ); }; }; window.location = test/index.html; })(__env__); I was wondering if you could either add a synchronized 'begin' or let log just be global $.extend(window, { ///... log: log?log:function(result, message); }); thanks thatcher -- Christopher Thatcher --~--~-~--~~~---~--~~ 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: jQuery.ajax cross domain request with script
Or, try the flXHRproxy plugin for jQuery... better cross-domain Ajax! http://flxhr.flensed.com/jquery.php --Kyle On May 15, 5:31 am, Ricardo ricardob...@gmail.com wrote: On May 14, 7:13 pm, hj2aj jianyi.huan...@gmail.com wrote: Hi there, I am having a problem with the cross domain issue that AJAX has. According to jQuery.ajax documentation, it should handle cross domain request with script and jsonp as data type. However, I cannot manage to get the following works: There is no error according to FireBug, all alerts were executed except the ones in 'success' and 'error' functions. The above example is very similar to something in Ubiquity developed by Mozilla, it works even with dataType: text, but in the 'success' function, it passed down a parameter and eval it. (I wonder whether in Mozilla it has a proxy to handle such request) jQuery.getScript() can handle cross domain request for sure, and it is based on jQuery.ajax with hardcoded dataType: script, however, I still want to have the request made on jQuery.ajax because it provides more controls. Can anyone please let me know why my example does not work, thanks!! jQuery adds a query string to the URL to avoid caching by default, likehttp://j.maxmind.com/app/geoip.js?_=1242383380394. As you can see that results in a blank page. Add cache: true to the ajax options and it should be fine. cheers -- ricardo- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: new $
I have only clients no boses, who blame it on jQuery until they are caught that is ;o) I am catching them with jQ version I have adorned with this kind of checks like the one we are discussing here. You will be amazed (same as me) what are javascript/css/html newcomers capable of doing. One more check I am going to add is this one to stop them doing new $ () ... Thanks --DBJ On May 15, 10:43 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Tell your head of whatever that a title in a contract does not necessary mean extraordinary skills and if he would like to improve his JavaScript knowledge he is more than welcome in this ml ( probably more as reader ... ) anyway ... function init(selector, context){ if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); }; function jQuery(selector, context) { return jQuery.fast ? new jQuery.fn.init(selector, context) : init.call(this, selector, context) ; }; Conditional is a bit faster than an if but still it is something that does not make sense because as I said the nature of the jQuery callback is dual ( both function/constructor ... it does not matter which way you call it, the result will always be an instance of jQuery, if you like weist time writing an alread implicit new everywhere, it cannot be a jQuery issue, do you agree? ) On Fri, May 15, 2009 at 10:20 AM, Daniel Friesen nadir.seen.f...@gmail.comwrote: ;) I still see an if statement there, heh. I prefer the conditional comments + build system approach. ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name] DBJDBJ wrote: ... If a user uses new $ this user simply does not truly understand/ know JavaScript but fortunately will not harm anybody... No it wont, unless this user is a team leader and starts blaming jQuery on everything. And this happens much more than anyone here (it seems) realises. But. This is another subject. PS: jQuery.fast = false ; jQuery.error_code = 0xABCD ; function(selector, context) { if ( ! jQuery.fast) if(this instanceof jQuery) throw new Error( jQuery.error_code, Can not new $()); return new jQuery.fn.init(selector, context); } On May 14, 2:59 pm, Andrea Giammarchi andrea.giammar...@gmail.com wrote: to do that you need to change the contructor: function(selector, context) { if(this instanceof jQuery) throw new Error(Can not new $()); return new jQuery.fn.init(selector, context); } this means an extra if for each jQuery call, something not that welcome for performances reason. At the same time, jQuery itself relies in this JavaScript peculiarity, so I would not create conflicts between jQuery developers and users. If a user uses new $ this user simply does not truly understand/know JavaScript but fortunately will not harm anybody. On Thu, May 14, 2009 at 10:23 AM, DBJDBJ dbj...@gmail.com wrote: Ah, new $, is possible and therefore not barred ... Left in there as a sort of a land-mine for the newcomers ? Or as an esoteric test for GC developers ? Highly useless it seems to me. Back to reality and jQuery. $ is defined as: function(selector, context) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init(selector, context); } Maybe I am just searching for ECMA harmony, but will $() definition that throws an exception if new-ed , be usefull : try { new $ ; } catch ( x ) { // x. message == Can not new $() } Au-contraire : will this hurt anyone ? Is exception throwing porgramming idiom damaging for jQuery? --DBJ PS: if Python was choosen as a Netscape scripting language, World would be a better place ... If nothing else its name is less ridiculous ... ;o) On May 14, 9:04 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: it's called JavaScript :D jokes a part, every function is a constructor as well so new function is always valid. If the function returns an object, it does not matter which new is because it will be an instance of returned object one. if it is a primitive it will simply be lost: var a = new function(){return 123;}; // a is an instance of anonymous function this allows us to create Python like initializations: function PythonLike(){ return this instanceof arguments.callee ? this : new arguments.callee; }; alert(PythonLike() instanceof PythonLike); alert(new PythonLike() instanceof PythonLike); true in both cases jQuery returns a new jQuery.prototype.init where init method shares the same prototype ... better now? :-) On Wed, May 13, 2009 at 11:57
[jquery-dev] Re: new $
For junior js developers it is normal, I would be surprised otherwise, the problem sometimes are company looking for skills but asking (paying) for a junior role junior==to learn this stuf, even useless, pro stuff ... that's it, and I still do not get the problem at all, sorry. On May 16, 2009 12:03 AM, DBJDBJ dbj...@gmail.com wrote: I have only clients no boses, who blame it on jQuery until they are caught that is ;o) I am catching them with jQ version I have adorned with this kind of checks like the one we are discussing here. You will be amazed (same as me) what are javascript/css/html newcomers capable of doing. One more check I am going to add is this one to stop them doing new $ () ... Thanks --DBJ On May 15, 10:43 am, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Tell your head of whatever that a title in a contract does not necessary mean extraordinary sk... nadir.seen.f...@gmail.comwrote: ;) I still see an if statement there, heh.I prefer the conditional comments + build... --~--~-~--~~~---~--~~ 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] Back to selectors
Hi quick help how can i go back to one selecotr in the hierarchy eg: ul id=selector ol id=list /ol br ul id=itens litest 01/li litest 02/li litest 03/li /ul /ul when i click on the LI tag its will be add same item on teh OL tag with this $(#selector ul li).click(function () { $str_option = $(this).text(); $( #list).append( li + $($str_option).selector + /li ); this work fine but if i have more those codes on the page... how can i use something without selector $( #list) can i uset the $(this) and back to a parent id? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---