[jQuery] BlockUI and ASP.NET
In regards to this blog post http://tiny.cc/y0vsz Elijah has been able to come up with a workaround for BlockUI. However even with this I'm having problems with ImageButton ASP.NET control. Anyone know of a way to mod BlockUI to better handle this?
[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)
For each click of the DIV I'm hoping to change the BackgroundColor, make some updates in the Database (depending on which array selection it's on) and that's about it. So, the first click of the DIV = Change BG to 'green', update DB field to 'XXX' the second click of the DIV = Change the BG to 'aqua', update DB field to 'YYY' the third click ... etc Know what I mean? On Oct 22, 6:04 pm, mkmanning michaell...@gmail.com wrote: Well, if you just want to loop through the array to change the background color, you don't really need toggle then. Try this: $(#item_list li div a).click(function(){ var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0, 255)','rgb(128, 0, 128)'], bgcolor = $.inArray($(this).css('background-color'),arrValues)+1; $(this).css('background-color',arrValues[bgcolor===arrValues.length? 0:bgcolor]); }); disclaimer: just wrote it inside Firebug's console, so haven't tested it outside that... On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote: Thanks, had a good read, figured it out in part. Now I'm stuck trying to introduce an array to do my bidding ... Example below. The array is an example of how I want to loop through to use those values. Underneath is the perfect code for clicking an Anchor and changing its BGcolour differently each time. Any ideas? $(document).ready( function(){ var arrValues = ['green','aqua','blue','purple']; $(#item_list li div a).toggle( function(){ $(this).css('background-color', 'green'); }, function() { $(this).css('background-color', 'aqua'); }, function() { $(this).css('background-color', 'blue'); }, function() { $(this).css('background-color', 'purple'); }); }); On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote: .toggle() allows you to rotate through multiple functions, you might want to check it out in the docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C... On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote: I've got one for ya, JQuery and Ajax. I want to have a button image, let's stay it's inactive state it's a grey circle, when someone clicks it once, it'd change to a blue circle (update associated DB field to blue), click it again and it becomes a red circle (update the DB field to red) and so on. So users keep clicking until they get the right color, then move on to the next one. I've seen something similar in Google where you can star emails with different stars. Any idea how you'd do this? It's got me stumped.
[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)
Thanks so much man, That'll work well ... One more thing, how would I change it to point to classes instead of direct colours? var arrValues = ['c1','c2','c3','c3'], Thanks again, On Oct 22, 6:27 pm, mkmanning michaell...@gmail.com wrote: Yeah, the snippet I wrote updates the color; you can add an ajax call to update your db as well, if the value your updating in the db is the color, or else the value is in an array that's indexed the same. On Oct 22, 12:10 am, The Danny Bos danny...@gmail.com wrote: For each click of the DIV I'm hoping to change the BackgroundColor, make some updates in the Database (depending on which array selection it's on) and that's about it. So, the first click of the DIV = Change BG to 'green', update DB field to 'XXX' the second click of the DIV = Change the BG to 'aqua', update DB field to 'YYY' the third click ... etc Know what I mean? On Oct 22, 6:04 pm, mkmanning michaell...@gmail.com wrote: Well, if you just want to loop through the array to change the background color, you don't really need toggle then. Try this: $(#item_list li div a).click(function(){ var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0, 255)','rgb(128, 0, 128)'], bgcolor = $.inArray($(this).css('background-color'),arrValues)+1; $(this).css('background-color',arrValues[bgcolor===arrValues.length? 0:bgcolor]); }); disclaimer: just wrote it inside Firebug's console, so haven't tested it outside that... On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote: Thanks, had a good read, figured it out in part. Now I'm stuck trying to introduce an array to do my bidding ... Example below. The array is an example of how I want to loop through to use those values. Underneath is the perfect code for clicking an Anchor and changing its BGcolour differently each time. Any ideas? $(document).ready( function(){ var arrValues = ['green','aqua','blue','purple']; $(#item_list li div a).toggle( function(){ $(this).css('background-color', 'green'); }, function() { $(this).css('background-color', 'aqua'); }, function() { $(this).css('background-color', 'blue'); }, function() { $(this).css('background-color', 'purple'); }); }); On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote: .toggle() allows you to rotate through multiple functions, you might want to check it out in the docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C... On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote: I've got one for ya, JQuery and Ajax. I want to have a button image, let's stay it's inactive state it's a grey circle, when someone clicks it once, it'd change to a blue circle (update associated DB field to blue), click it again and it becomes a red circle (update the DB field to red) and so on. So users keep clicking until they get the right color, then move on to the next one. I've seen something similar in Google where you can star emails with different stars. Any idea how you'd do this? It's got me stumped.
[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)
Thanks man, I'll give it a whirl ... Thanks for all your time and energy. d On Oct 23, 4:19 am, mkmanning michaell...@gmail.com wrote: Something like this (untested): var arrValues = ['c1','c2','c3','c3'], cnameIndex = $.inArray(this.className,arrValues)+1; this.className = cnameIndex===arrValues.length?0: cnameIndex ]; if you can live with only one classname, otherwise you'll have to add code to remove the old classname from arrValues and then add the new class with addClass. Basically all this is doing is getting the current value of a given property, such as background-color, finding its index in the arrValues array, incrementing that by one and then setting the new value to the element in the array with the incremented index. If the index is at the end of the array, it resets to 0. On Oct 22, 4:39 am, The Danny Bos danny...@gmail.com wrote: Thanks so much man, That'll work well ... One more thing, how would I change it to point to classes instead of direct colours? var arrValues = ['c1','c2','c3','c3'], Thanks again, On Oct 22, 6:27 pm, mkmanning michaell...@gmail.com wrote: Yeah, the snippet I wrote updates the color; you can add an ajax call to update your db as well, if the value your updating in the db is the color, or else the value is in an array that's indexed the same. On Oct 22, 12:10 am, The Danny Bos danny...@gmail.com wrote: For each click of the DIV I'm hoping to change the BackgroundColor, make some updates in the Database (depending on which array selection it's on) and that's about it. So, the first click of the DIV = Change BG to 'green', update DB field to 'XXX' the second click of the DIV = Change the BG to 'aqua', update DB field to 'YYY' the third click ... etc Know what I mean? On Oct 22, 6:04 pm, mkmanning michaell...@gmail.com wrote: Well, if you just want to loop through the array to change the background color, you don't really need toggle then. Try this: $(#item_list li div a).click(function(){ var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0, 255)','rgb(128, 0, 128)'], bgcolor = $.inArray($(this).css('background-color'),arrValues)+1; $(this).css('background-color',arrValues[bgcolor===arrValues.length? 0:bgcolor]); }); disclaimer: just wrote it inside Firebug's console, so haven't tested it outside that... On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote: Thanks, had a good read, figured it out in part. Now I'm stuck trying to introduce an array to do my bidding ... Example below. The array is an example of how I want to loop through to use those values. Underneath is the perfect code for clicking an Anchor and changing its BGcolour differently each time. Any ideas? $(document).ready( function(){ var arrValues = ['green','aqua','blue','purple']; $(#item_list li div a).toggle( function(){ $(this).css('background-color', 'green'); }, function() { $(this).css('background-color', 'aqua'); }, function() { $(this).css('background-color', 'blue'); }, function() { $(this).css('background-color', 'purple'); }); }); On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote: .toggle() allows you to rotate through multiple functions, you might want to check it out in the docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C... On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote: I've got one for ya, JQuery and Ajax. I want to have a button image, let's stay it's inactive state it's a grey circle, when someone clicks it once, it'd change to a blue circle (update associated DB field to blue), click it again and it becomes a red circle (update the DB field to red) and so on. So users keep clicking until they get the right color, then move on to the next one. I've seen something similar in Google where you can star emails with different stars. Any idea how you'd do this? It's got me stumped.
[jQuery] Click multiple times, different states, saves different data to DB (confusing?)
I've got one for ya, JQuery and Ajax. I want to have a button image, let's stay it's inactive state it's a grey circle, when someone clicks it once, it'd change to a blue circle (update associated DB field to blue), click it again and it becomes a red circle (update the DB field to red) and so on. So users keep clicking until they get the right color, then move on to the next one. I've seen something similar in Google where you can star emails with different stars. Any idea how you'd do this? It's got me stumped.
[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)
Thanks, had a good read, figured it out in part. Now I'm stuck trying to introduce an array to do my bidding ... Example below. The array is an example of how I want to loop through to use those values. Underneath is the perfect code for clicking an Anchor and changing its BGcolour differently each time. Any ideas? $(document).ready( function(){ var arrValues = ['green','aqua','blue','purple']; $(#item_list li div a).toggle( function(){ $(this).css('background-color', 'green'); }, function() { $(this).css('background-color', 'aqua'); }, function() { $(this).css('background-color', 'blue'); }, function() { $(this).css('background-color', 'purple'); }); }); On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote: .toggle() allows you to rotate through multiple functions, you might want to check it out in the docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C... On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote: I've got one for ya, JQuery and Ajax. I want to have a button image, let's stay it's inactive state it's a grey circle, when someone clicks it once, it'd change to a blue circle (update associated DB field to blue), click it again and it becomes a red circle (update the DB field to red) and so on. So users keep clicking until they get the right color, then move on to the next one. I've seen something similar in Google where you can star emails with different stars. Any idea how you'd do this? It's got me stumped.
[jQuery] Re: Remote Success message
This is of course the Validator Plugin, but someone must have some insight into how to add this functionality? I've looked, it's not there.
[jQuery] Remote Success message
Hi, I'm trying to figure out how to display a Success Message upon remote returning 'true'. Yes, I know this can be done with success: function() {}, however I have multiple fields that I want to use this on, and I want to display more than just a generic message. Let's say I have a Username and Email field, both of which are being validated remotely (via remote), and I want to display a Success message (Username not in use, Email not in use, respectively). Is there anyway I can do this? Can I retrieve the label information that would be unique to Username or Email fields, then use that to identify the fields and dynamically generate the words 'Username' and 'Email'? Is there a default message for remote returning 'true'? I know there's a default one for 'false', I don't get the point behind adding one and not the other... Any help would be appreciated, thanks.
[jQuery] ajax request form in one page, is it possible ?
Hello, I want to build a form that work on one page only, to subtract the PHP pages for getting the data from all my web forms, I tried to pass the parameters to the same page but it dosent work :( i'll be glad if you can direct me to the solution Thanks
[jQuery] Re: ajax request form in one page, is it possible ?
I understand that ive to use - X-Requested-With then I did search a bit about that and I found this code, $.ajaxSetup({ headers: {X-Requested-With:Ajax} }); but I still don't understand how should I send the parameters to the same file and get them in the server side (PHP) I hot to get answer, thanks!
[jQuery] Cross-domain (for analytics)
I've run up against a cross-domain Ajax problem, essentially I want to do something like: (in http://hostA.com/page.html) script $.ajax({ type: POST, url: http://hostB.com/service.php;, data: dataText, ... but this promptly produces an [Exception... Access to restricted URI denied code: 1012... The thing is, unlike most of the related scenarios I've found, I don't actually want anything back from the server, I just want to send off some page access data. Because ultimately I want this thing to be easy for end-users, the use of a server-side proxy is something I'd like to avoid. I'm pretty sure this should be doable /somehow/ - it appears that Google Analytics must get around the problem, but I haven't been able to suss out how. Suggestions? (the code I'm working on is linked from http://hyperdata.org/wiki/wiki/TtrackerHowItWorks ) Cheers, Danny.
[jQuery] Re: Cross-domain (for analytics)
Many thanks folks. I wound up opting for a hidden form (thanks for the twit Laurian!) - it allowed me to do a sweet RESTful POST and because I didn't need anything back from the server there was no need to get my hands dirty with iFrames. Maybe jQuery could benefit from such a feature? Anyhow I did a little write-up of the options I found for cross-domain Ajax at: http://blogs.talis.com/n2/archives/770 Cheers, Danny.
[jQuery] Re: Image Processing!!
There are people using canvas elements to do image processing in Javascript; see http://ejohn.org/blog/ocr-and-neural-nets-in-javascript/ and http://www.pixastic.com/ On Jun 24, 2:03 pm, rosie marzmur...@gmail.com wrote: Hi there, Just wondering is it possible to take an image, for instance an item of clothing and remove the background (all one block color), or make it transparent so that the item of clothing which was uploaded onto a portfolio on a website can be fited onto a model...to be done automaticaly using jQuery. Thanks, Rosie
[jQuery] Re: selector question
You probably don't want the '#' character in there: $(div:not(+pid+) form span).css(background-color,yellow); On Jun 9, 11:45 am, mkmanning michaell...@gmail.com wrote: $(div:not(#+pid+) form span).css(background-color,yellow); On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote: Hi, Im trying to select all spans in divs containing forms that dont have a certain id $(div:not([id='#'+pid]) form span).css(background-color, yellow); This selects all spans regardless of the ID.. Any suggestions would be great! Thanks in advance...
[jQuery] Re: JQuery UI Accordion Plugin
First is the code you cant see. Any and all post document ready changes are not visible by view page source. Instead, select the object with your mouse, right click, and view selection source. As for the accordion, not so sure there! --- On Mon, 5/25/09, Bharat bcrupa...@yahoo.com wrote: From: Bharat bcrupa...@yahoo.com Subject: [jQuery] JQuery UI Accordion Plugin To: jQuery (English) jquery-en@googlegroups.com Date: Monday, May 25, 2009, 6:55 PM I am a Rails developer and new to jQuery so this may be a naive question: I am using jQuery Accordion plugin in my project and it is working, but now I am trying to tweak it and do not know how to: So I have a page that displays comments as a stack of accordion folds. This is the code in my application.html.erb (master layout) file: $(#accordion).accordion({ autoHeight: false, event: 'mouseover' }); This works fine. There is a Rails form on this page where I allow the users to create a comment, and submit it. Upon submission, the prepends the notes record as shown below: $(#accordion).prepend(%= escape_javascript(render(:partial = 'shared/comment', :object = @comment)) %); $(#new_comment)[0].reset(); What is totally confusing me is that this is showing on the page, but is not a part of the accordion. As a matter of fact, when I view the page source, the entry is not even there on the page, yet it is being shown in the browser. How could that be? There is something fundamental that I am missing here. Kindly explain. Thanks. Bharat
[jQuery] Re: jQuery XML
So, first: html = 'img src=' + ($(this).find(xmlvar).text()) + '' + ($(this).find(titletext).text()) + '\n\n'; Create a variable with the code needed. $(div).append($(html)); Then dump it to the div. Order and logic you need to figure out, but thats an example of how to dump a xml returned result into a file. --- On Wed, 5/20/09, alex boba...@googlemail.com wrote: From: alex boba...@googlemail.com Subject: [jQuery] jQuery XML To: jQuery (English) jquery-en@googlegroups.com Date: Wednesday, May 20, 2009, 11:51 AM I have this XML file, and I've gotten a few values from it, but I need one more, a create a variable from it, and insert that in to an img tag. XML : http://itiz.in/idvt JS : http://itiz.in/318m So as is clear, getting the track name etc. is fine, but I want the medium sized album art to be inserted in to an img tag (img src=medium_sized_image_url alt=). I've tried searching but can't find anything, I'm doubly interested because I wouldn't mind using the URL that's in there as well.
[jQuery] Re: Sortable accordion-like widget
Example? Im very new to jQuery, the old code was partially provided by someone else with a few edits, so not sure how to create that new level you was talking about. --- On Thu, 5/14/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Thursday, May 14, 2009, 10:12 PM You'll need to add an extra level: section divs containing each related h3 and content div. Then you can call .sortable() the main div#accordion1 - Richard On Thu, May 14, 2009 at 9:38 PM, DanN danny_no...@yahoo.co.uk wrote: Got this coded, its an accordion like tool. It functions just how I need it, except id love to make it sortable. Anyone help with the code update? jQuery : $(function() { $(#accordion1).addClass(ui-accordion ui-widget ui-helper-reset) .find(h3) .addClass(ui-accordion-header ui-helper-reset ui-state-default ui- corner-top ui-corner-bottom) .prepend('span class=ui-icon ui-icon-triangle-1-e/') .hover(function() { $(this).addClass(ui-state-hover); }, function() { $(this).removeClass(ui-state-hover); }) .click(function() { $(this).toggleClass(ui-accordion-header-active).toggleClass(ui- state-active) .toggleClass(ui-state-default).toggleClass(ui-corner-bottom) .find( .ui-icon).toggleClass(ui-icon-triangle-1-e).toggleClass (ui-icon-triangle-1-s) .end().next().toggleClass(ui-accordion-content-active).toggle(); return false; }) .next().addClass(ui-accordion-content ui-helper-reset ui-widget- content ui-corner-bottom).hide(); }) HTML: div id=accordion1 h3a href=#DRAW2/a/h3 div CONTENT /div h3a href=#DRAW2/a/h3 div CONTENT /div /div Help appreciated in advance.
[jQuery] Re: how to uncheck the check box
Change to a standard radio group? --- On Fri, 5/15/09, bharani kumar bharanikumariyer...@gmail.com wrote: From: bharani kumar bharanikumariyer...@gmail.com Subject: [jQuery] how to uncheck the check box To: jquery-en@googlegroups.com Date: Friday, May 15, 2009, 9:38 AM Hi all Can u tell me , how to uncheck the check box , when i check another check box, for example having 4 check boxes, be default check box is checked ,. when i check the check box 2 , then need to uncheck the checked one , How to do this in jquery , Thanks -- உங்கள் நண்பன் பரணி குமார் Regards B.S.Bharanikumar POST YOUR OPINION http://bharanikumariyerphp.site88.net/bharanikumar/
[jQuery] Re: Sortable accordion-like widget
Almost, I found it worked almost, except for the fact that the sortable affected only the UL-LI objects, the contents were static. How to get past that? --- On Fri, 5/15/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Friday, May 15, 2009, 10:51 AM Sure, here you go: http://jsbin.com/aqeca You can edit this example here: http://jsbin.com/aqeca/edit It's not perfect, since when you sort one, it also toggles it, but it's a start. - Richard On Fri, May 15, 2009 at 10:19 AM, Danny Nolan danny_no...@yahoo.co.uk wrote: Example? Im very new to jQuery, the old code was partially provided by someone else with a few edits, so not sure how to create that new level you was talking about. --- On Thu, 5/14/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Thursday, May 14, 2009, 10:12 PM You'll need to add an extra level: section divs containing each related h3 and content div. Then you can call .sortable() the main div#accordion1 - Richard On Thu, May 14, 2009 at 9:38 PM, DanN danny_no...@yahoo.co.uk wrote: Got this coded, its an accordion like tool. It functions just how I need it, except id love to make it sortable. Anyone help with the code update? jQuery : $(function() { $(#accordion1).addClass(ui-accordion ui-widget ui-helper-reset) .find(h3) .addClass(ui-accordion-header ui-helper-reset ui-state-default ui- corner-top ui-corner-bottom) .prepend('span class=ui-icon ui-icon-triangle-1-e/') .hover(function() { $(this).addClass(ui-state-hover); }, function() { $(this).removeClass(ui-state-hover); }) .click(function() { $(this).toggleClass(ui-accordion-header-active).toggleClass(ui- state-active) .toggleClass(ui-state-default).toggleClass(ui-corner-bottom) .find( .ui-icon).toggleClass(ui-icon-triangle-1-e).toggleClass (ui-icon-triangle-1-s) .end().next().toggleClass(ui-accordion-content-active).toggle(); return false; }) .next().addClass(ui-accordion-content ui-helper-reset ui-widget- content ui-corner-bottom).hide(); }) HTML: div id=accordion1 h3a href=#DRAW2/a/h3 div CONTENT /div h3a href=#DRAW2/a/h3 div CONTENT /div /div Help appreciated in advance.
[jQuery] Re: Sortable accordion-like widget
Let me be more specific, this is the code I have: $(function() { $(#accordion1).addClass(ui-accordion ui-widget ui-helper-reset) .find(h3) .addClass(ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom) .prepend('span class=ui-icon ui-icon-triangle-1-e/') .hover(function() { $(this).addClass(ui-state-hover); }, function() { $(this).removeClass(ui-state-hover); }) .click(function() { $(this).toggleClass(ui-accordion-header-active).toggleClass(ui-state-active) .toggleClass(ui-state-default).toggleClass(ui-corner-bottom) .find( .ui-icon).toggleClass(ui-icon-triangle-1-e).toggleClass(ui-icon-triangle-1-s) .end().next().toggleClass(ui-accordion-content-active).toggle(); return false; }) .next().addClass(ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom).hide(); //$(#accordion1).sortable(); }) Where am I going wrong? --- On Fri, 5/15/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Friday, May 15, 2009, 10:51 AM Sure, here you go: http://jsbin.com/aqeca You can edit this example here: http://jsbin.com/aqeca/edit It's not perfect, since when you sort one, it also toggles it, but it's a start. - Richard On Fri, May 15, 2009 at 10:19 AM, Danny Nolan danny_no...@yahoo.co.uk wrote: Example? Im very new to jQuery, the old code was partially provided by someone else with a few edits, so not sure how to create that new level you was talking about. --- On Thu, 5/14/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Thursday, May 14, 2009, 10:12 PM You'll need to add an extra level: section divs containing each related h3 and content div. Then you can call .sortable() the main div#accordion1 - Richard On Thu, May 14, 2009 at 9:38 PM, DanN danny_no...@yahoo.co.uk wrote: Got this coded, its an accordion like tool. It functions just how I need it, except id love to make it sortable. Anyone help with the code update? jQuery : $(function() { $(#accordion1).addClass(ui-accordion ui-widget ui-helper-reset) .find(h3) .addClass(ui-accordion-header ui-helper-reset ui-state-default ui- corner-top ui-corner-bottom) .prepend('span class=ui-icon ui-icon-triangle-1-e/') .hover(function() { $(this).addClass(ui-state-hover); }, function() { $(this).removeClass(ui-state-hover); }) .click(function() { $(this).toggleClass(ui-accordion-header-active).toggleClass(ui- state-active) .toggleClass(ui-state-default).toggleClass(ui-corner-bottom) .find( .ui-icon).toggleClass(ui-icon-triangle-1-e).toggleClass (ui-icon-triangle-1-s) .end().next().toggleClass(ui-accordion-content-active).toggle(); return false; }) .next().addClass(ui-accordion-content ui-helper-reset ui-widget- content ui-corner-bottom).hide(); }) HTML: div id=accordion1 h3a href=#DRAW2/a/h3 div CONTENT /div h3a href=#DRAW2/a/h3 div CONTENT /div /div Help appreciated in advance.
[jQuery] Re: Sortable accordion-like widget
yep, took me a while to realize that :) Implemented the extra layer of divs and its working great! Thank you so much! UL-LIs was for the tabs above, not involved, my mistake :) --- On Fri, 5/15/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Friday, May 15, 2009, 2:04 PM What UI-LI objects? Your sample code (which I added an extra div level to) only has DIVs and H3s. - Richard On Fri, May 15, 2009 at 2:21 PM, Danny Nolan danny_no...@yahoo.co.uk wrote: Almost, I found it worked almost, except for the fact that the sortable affected only the UL-LI objects, the contents were static. How to get past that? --- On Fri, 5/15/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Friday, May 15, 2009, 10:51 AM Sure, here you go: http://jsbin.com/aqeca You can edit this example here: http://jsbin.com/aqeca/edit It's not perfect, since when you sort one, it also toggles it, but it's a start. - Richard On Fri, May 15, 2009 at 10:19 AM, Danny Nolan danny_no...@yahoo.co.uk wrote: Example? Im very new to jQuery, the old code was partially provided by someone else with a few edits, so not sure how to create that new level you was talking about. --- On Thu, 5/14/09, Richard D. Worth rdwo...@gmail.com wrote: From: Richard D. Worth rdwo...@gmail.com Subject: [jQuery] Re: Sortable accordion-like widget To: jquery-en@googlegroups.com Date: Thursday, May 14, 2009, 10:12 PM You'll need to add an extra level: section divs containing each related h3 and content div. Then you can call .sortable() the main div#accordion1 - Richard On Thu, May 14, 2009 at 9:38 PM, DanN danny_no...@yahoo.co.uk wrote: Got this coded, its an accordion like tool. It functions just how I need it, except id love to make it sortable. Anyone help with the code update? jQuery : $(function() { $(#accordion1).addClass(ui-accordion ui-widget ui-helper-reset) .find(h3) .addClass(ui-accordion-header ui-helper-reset ui-state-default ui- corner-top ui-corner-bottom) .prepend('span class=ui-icon ui-icon-triangle-1-e/') .hover(function() { $(this).addClass(ui-state-hover); }, function() { $(this).removeClass(ui-state-hover); }) .click(function() { $(this).toggleClass(ui-accordion-header-active).toggleClass(ui- state-active) .toggleClass(ui-state-default).toggleClass(ui-corner-bottom) .find( .ui-icon).toggleClass(ui-icon-triangle-1-e).toggleClass (ui-icon-triangle-1-s) .end().next().toggleClass(ui-accordion-content-active).toggle(); return false; }) .next().addClass(ui-accordion-content ui-helper-reset ui-widget- content ui-corner-bottom).hide(); }) HTML: div id=accordion1 h3a href=#DRAW2/a/h3 div CONTENT /div h3a href=#DRAW2/a/h3 div CONTENT /div /div Help appreciated in advance.
[jQuery] Re: Global variables in jQuery
Are you sure the data is coming back the way you expect? Put an alert (data) in the callback function. On May 13, 3:02 am, V vincenti...@gmail.com wrote: I can't get global variables work, maybe somebody knows the answer because this should be very simple. The following does not work, the price is not available at the end of the function in the alert. function calc_matrix(x, y) { loc = index.php?module=product; var price = 0; $.post(loc, { request:xmlhttp, action:calc_pricematrix, x:x, y:y }, function(data) { price = Math.round(parseFloat(data)*100)/100; }); alert(price); }
[jQuery] Re: POST Redirection
got it installed? Enable it, have it running while viewing the form. Now submit the form and firebug will capture the post URL, will popup inside the firebug window. --- On Sat, 5/2/09, Cryptonit dom.helfenst...@gmail.com wrote: From: Cryptonit dom.helfenst...@gmail.com Subject: [jQuery] Re: POST Redirection To: jQuery (English) jquery-en@googlegroups.com Date: Saturday, May 2, 2009, 9:20 AM Could you please be a little more precise? I've installed firebug, now what? Maybe I also have to be more specific: I don't create a web page, I'm creating a firefox extension. So I can't just debug everything I like... Could you please point me to the exact property I have to look for? On 2 Mai, 02:07, Danny Nolan danny_no...@yahoo.co.uk wrote: Firebug is your friend --- On Fri, 5/1/09, Cryptonit dom.helfenst...@gmail.com wrote: From: Cryptonit dom.helfenst...@gmail.com Subject: [jQuery] POST Redirection To: jQuery (English) jquery-en@googlegroups.com Date: Friday, May 1, 2009, 2:22 PM Hi Folks! Here's my problem: I want to make a post request to a web service site. This site is automaticly redirecting me to a file. Now I want to find out the location of this file. As far as I can see (please correct me if there are more) there are two possible solutions: 1. I somehow disable redirecting (on jQuery) and so I would have the link to the file in the answer of my call 2. Or I read the final location after the redirection But of course I don't know how to do this... So I really hope someone can help me! Greetz cryptonit
[jQuery] Re: POST Redirection
Firebug is your friend --- On Fri, 5/1/09, Cryptonit dom.helfenst...@gmail.com wrote: From: Cryptonit dom.helfenst...@gmail.com Subject: [jQuery] POST Redirection To: jQuery (English) jquery-en@googlegroups.com Date: Friday, May 1, 2009, 2:22 PM Hi Folks! Here's my problem: I want to make a post request to a web service site. This site is automaticly redirecting me to a file. Now I want to find out the location of this file. As far as I can see (please correct me if there are more) there are two possible solutions: 1. I somehow disable redirecting (on jQuery) and so I would have the link to the file in the answer of my call 2. Or I read the final location after the redirection But of course I don't know how to do this... So I really hope someone can help me! Greetz cryptonit
[jQuery] IE: jQuery leaking memory on blank page
Hi all, I've been trying to fix some memory leaks in my app. As I was stripping the code down I discovered that even on a totally blank page that includes jQuery, memory is leaked. If you point Drip at the jquery.com homepage you'll see quite a few elements left around after the page unloads. It seems to be mostly stuff in jquery.support (script tags, anchor tags, divs) that are used to test browser capabilities. Is this a known issue? Is there any workaround? It seems to be the removeChild calls causing most of it (but removing them obviously laves random elements in the dom). Our app is likely to be kept open in the browser for the entire day, with a lot of page loads, so we're keen to address any memory leaks. Any ideas what I can do about this?
[jQuery] datepicker highlight individual days
Hi, Is there a way to highlight or enable for selection individual days ( not a range of days ) in a datepicker? Thanks in advance, Danny
[jQuery] Re: Using JQuery instead of the Java applet for a web cam. Ideas? Suggestions?
Changing the image source is the simplest Ajaxy thing to do, just $ ('#webcamimage').attr('src', 'http://example.com/cam.jpg'). If the filename is always the same, the browser will use the version of the image from cache, which is not what you want. Add a query string to change the filename: $('#webcamimage').attr('src', 'http://example.com/cam.jpg?time='+Date ()) Danny On Feb 12, 4:30 pm, James james.gp@gmail.com wrote: You can use Javascript's setInterval function to constantly do a check to update an image source. How does the filename look like? Is it predictable? On Feb 12, 12:15 pm, lampshade mwolff...@gmail.com wrote: Hello, I was given a web cam to use, but unfortunately it pulls the image into a page via an applet. The applet kills the page load time turning it into a 5-6 second wait. In addition to the Java applet, the camera will FTP an image to a single filename every X seconds. I'm wondering if I can use that feature combined with JQuery and maybe JQuery Cycle Plugin to do something better than the Java applet? I'm just looking for general advice or ideas right now. Thanks in advance,
[jQuery] Re: error with selector using jquery.ifixpng2.js and jquery v1.3.1
jQuery 1.3 finally got rid of the '@' in selectors. Just use 'img[src $=.png]' On Jan 25, 8:04 am, mcologne blueameri...@web.de wrote: hi, there comes an error with the following selector... i'm using jquery.ifixpng2.js or (jquery.ifixpng.js) and jquery-1.3.1.min.js $('i...@src$=.png]').ifixpng(); Exception... 'Syntax error, unrecognized expression: [...@src$=.png]' when calling method: [nsIDOMEventListener::handleEvent... what is wrong with this selector? best regards m from cologne
[jQuery] New to JQuery: First Question (animating background image)
All, I just started work with jQuery just recently, and I'm beginning to love it. I'm a Prototype convert, and I love the increased power of jQuery. New to it though, I'm running into some trouble already. I'm trying to flip between different background images, with CSS set initially to the BODY tag. The goal is to produce a slideshow in the background of page. I cannot for the life figure of why this code isn't changing the background image of the BODY tag. I'm beginning to think it's a DOM limitation of some sort, but in case I am overlooking something, I thought I would post it here: $(document).ready(function() { $(body).animate( { backgroundImage:url(/images/test-backgrounds/ china_chinese_chinglish_1432992_o.jpg)}, 1000 ) .animate({opacity: 1.0}, 1000) .animate( { backgroundImage:url(/images/test-backgrounds/ google_scifoo_camp_291462_o.jpg)}, 1000 ) }); What I think this should be doing is setting the background, pausing (what I am using the opacity call for), and then changing the image. Again, any help is most welcome. Thank you very much in advance.
[jQuery] Re: firebug regression: console.log($('div')) less useful
Thanks; I didn't know about console.dir(). My workaround puts it on fewer lines, without all the jQuery plugins, so it's more useful. On Jan 2, 9:59 am, Dan G. Switzer, II dswit...@pengoworks.com wrote: It's a Firebug change. Use console.dir() instead (but I agree--I like the old console.log() method) On Fri, Jan 2, 2009 at 1:10 AM, Danny d.wac...@prodigy.net wrote: Has anyone else noticed that Firebug before 1.2 would treat console.log ($('div')) as an array and list all the matched elements on the console, so you could mouse over the list and highlight the elements, or right-click and scroll into view etc., but now it just lists Object length=13 and you need to click on that, then you get a vertical list that you need to scroll through. The old way was more helpful, I think. John Resig, you're the Mozilla Firebug person as well as the jQuery Man; can this be fixed? Workaround: console.log.apply(console, $('div').get()) comes close to reproducing the old behavior. I'll crosspost this on the Firebug list.
[jQuery] firebug regression: console.log($('div')) less useful
Has anyone else noticed that Firebug before 1.2 would treat console.log ($('div')) as an array and list all the matched elements on the console, so you could mouse over the list and highlight the elements, or right-click and scroll into view etc., but now it just lists Object length=13 and you need to click on that, then you get a vertical list that you need to scroll through. The old way was more helpful, I think. John Resig, you're the Mozilla Firebug person as well as the jQuery Man; can this be fixed? Workaround: console.log.apply(console, $('div').get()) comes close to reproducing the old behavior. I'll crosspost this on the Firebug list.
[jQuery] Re: Installation
Sounds like you are trying to use the file by double-clicking it in Windows. You don't have to do that; there's no installation. It's ready to use. Include the line script type=text/javascript src=path/to/jquery-1.2.6.js/script in your HTML file and jQuery away! Danny On Nov 2, 3:47 pm, minu [EMAIL PROTECTED] wrote: Hello All I was trying to download and install Jquery . I am using the following link.http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js When i try to run this script i get an error.Also i am surprised to see the file size to be just 97.8 Kb. The error i get is 'Window is undefined' Please help Thanks Minu
[jQuery] Re: jquery 1.2.3, validation plugin 1.1, and IE6
In my experience, problems of Works in FF but silently fails in IE are almost always extra commas at the end of objects -- {a: 1, b:2, } sorts of things. On Thu, Sep 11, 2008 at 5:04 PM, Andy Matthews [EMAIL PROTECTED] wrote: A coworker is trying to use this combination of codes to get a basic validation working for a form he's building. It works just fine in FF2, but does nothing in IE6, with no errors. Does anyone know of any reason why this shouldn't work?
[jQuery] Re: $(xx).load can't load css and js in html file on Chrome??
According to the W3C standard, style elements can only go in the head. It's a dumb rule, but it's the rule. IE and Firefox are happy to put the style in the body, but Safari won't do it (it ignores styles when setting innerHTML) and I assume Chrome, which is based on WebKit, does the same. You have to split your loaded file into separate HTML and CSS, and append a link rel=stylesheet or style to the head for the CSS. It's a pain, but it is the standard so it's hard to fault WebKit. On Sep 8, 11:27 am, Andy Matthews [EMAIL PROTECTED] wrote: Gotcha. -Original Message- From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jove Sent: Monday, September 08, 2008 10:41 AM To: jQuery (English) Subject: [jQuery] Re: $(xx).load can't load css and js in html file on Chrome?? I' sorry, xx just a example, in actually I'm using $ (#content).load(), but the point of this topic is about .load() on Chrome.
[jQuery] Re: Selecting a checkbox by clicking anywhere on a row
add return false; to your click handler to keep the click from getting to the checkbox itself. Danny On Sep 8, 10:55 am, Michael Smith [EMAIL PROTECTED] wrote: Hi there, I'm trying to make a page which automatically toggles a checkbox when you click anywhere on the row. Here's a version I've cut down to the bare bones to illustrate http://dev.savingforchildren.co.uk/mjs/row_select.epl It seems to work fine unless the user actually clicks on the checkbox itself. In this case it seems that it actually gets toggled twice and so reverts to its original state. Any suggestions on the cleanest / simples way to avoid this? (I can think of a few messy ways) Thanks Michael
[jQuery] Re: Wrap tagless text fragments?
A quick plugin that I think will work for you: $.fn.orphans = function(){ var ret = []; this.each(function(){$.each(this.childNodes, function() {if (this.nodeType == 3) ret.push(this)})}); return $(ret); } You may want to test for empty text nodes though; change the if clause to (this.nodeType == 3 $.trim(this.nodeValue)) Danny On Aug 28, 2:30 pm, Steven Black [EMAIL PROTECTED] wrote: I develop and host wikis where users enter free-form text, and my server-side parsers create WISIWYG HTML from this. Of course, users can, and do, submit almost anything, and on the server-side I do a pretty good job of marking it up properly. But addressing edge-cases makes the server-side parsing increasingly heavy. One such edge case is islands of text that are not in any tag other than the global containing DIV. Like this: div class=container h3I am text within a tag/h3 I am a text island child of the container div wrapper. --- My edge case pI am also text within a tag/p /div QUESTION: Using jQuery, how would you select orphan text inside a DIV in order to $.wrap() it, say, in a p tag? I'm thinking I could ask the client browsers to address some of these edge-cases for me. Ideas? Something like $ (.container).textFragmentsNotInsideAnyOtherTag() **--** Steve
[jQuery] Re: attr(style: ) vs. css
Also attr('style', 'prop:val') replaces the entire inline style. css() just replaces that property. Danny On Jul 19, 12:37 pm, Geir [EMAIL PROTECTED] wrote: Thanks!
[jQuery] Re: A simple plugin to check if your browser supported by jQuery - Officially
I could find this useful, but I think it ought to be in the jQuery core since the list of supported browsers changes with each release. I proposed this on the jQuery-dev list but got my head chewed off by people who felt browser-sniffing was too evil to ever allow. I wonder if there is any way to do capability testing without importing the whole jQuery test suite? Just a small set of things that are known to fail on unsupported browsers? Danny On May 22, 10:36 am, howa [EMAIL PROTECTED] wrote: Just share with you one of a useful plugin: jQuery.supported = function() { if (typeof jQuery.supported.result != undefined) return jQuery.supported.result; jQuery.supported.browsers = [ [safari, 412], [opera, 9.0], [msie, 6.0], [mozilla, 1.8.1] ]; jQuery.supported.result = false; var b = jQuery.supported.browsers; for (var i=0; ib.length; i++){ if (typeof jQuery.browser[b[i][0]] != undefinded jQuery.browser[b[i][0]]) { var a1 = b[i][1].split(.); var a2 = jQuery.browser.version.split(.); var d1 = a1.shift(); var d2 = a2.shift(); if ( parseFloat(d2 + . + a2.join()) = parseFloat(d1 + . + a1.join()) ) jQuery.supported.result = true; } } return jQuery.supported.result; }; // To use alert( jQuery.supported () );
[jQuery] Re: Google Maps / JQuery
I suspect the problem is the window.onload=load line. That replaces any existing onload function (such as jQuery itself) with your function. I would use $(load) to add your load() function to jQuery's document.ready queue. Danny On May 15, 6:45 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, i´m using JQuery. Overall no problem... just with Google Maps it does not work at all. While loading the code attached in the head/head area, all other JQuery Code stop working and are reported as error. Anybody who can fix this ? Thanks alot. For example: - $(#login-box) has no properties (no name)()test.js (line 19) e()jquery.js (line 11) e()jquery.js (line 11) e([function(), function()], function(), undefined)jquery.js (line 11) e()jquery.js (line 11) [Break on this error] $(#login-box).hide(); - Code - script src=http://maps.google.com/maps? file=apiamp;v=2amp;key={gmaps_key} type=text/javascript/script script type=text/javascript //![CDATA[ var map = null; var geocoder = null; window.onload=load function load() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById(map)); geocoder = new GClientGeocoder(); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); //map.setCenter(new GLatLng(37.4419, -122.1419), 13); var posi = new GLatLng({gmaps_lat}, {gmaps_long}); map.setCenter(posi, 13); map.addOverlay(new GMarker(posi)); GEvent.addListener(map, click, function(marker, point) { if (marker) { map.removeOverlay(marker); } else { map.clearOverlays(); map.addOverlay(new GMarker(point)); updateGeo(point.x, point.y); } }); } } function showAddress() { var street = document.useraddress.address.value; var zipcode = document.useraddress.zipcode.value; var city = document.useraddress.city.value; var countries = document.useraddress.country; var country = countries.options[countries.selectedIndex].innerHTML; var address = ; var sep = ; if(street) {address += sep + street; sep = , ;} if(zipcode) {address += sep + zipcode; sep = , ;} if(city) {address += sep + city; sep = , ;} if(country) {address += sep + country; sep = , ;} geocoder.getLatLng( address, function(point) { if (!point) { alert(address + nicht gefunden); } else { //map.setCenter(point, 13); map.clearOverlays(); var marker = new GMarker(point); map.addOverlay(marker); updateGeo(point.x, point.y); //marker.openInfoWindowHtml(address); } } ); } function updateGeo(long, lat) { assignFieldValue('gmaps_lat',lat); assignFieldValue('gmaps_long',long); map.setCenter(new GLatLng(lat, long)); } //]] /script -
[jQuery] Re: storing jquery object in array
You're probably assigning to searchbox before the #searchinput element exists: head script $.searchfunction = { searchbox: $('#searchinput) } // empty jQuery object because body hasn't been created yet /script /head body div id=searchinput/div script console.log ($('#searchinput')); // one element in jQuery object console.log ($.searchfunction.searchbox); // no elements--you aren't re-running the query, just using the failed one from earlier /script /body Solution: put the initial assignment in a $(document).ready function, so it won't be assigned until the entire DOM is available. On Apr 3, 7:19 pm, ScottBruin [EMAIL PROTECTED] wrote: Please pardon my poor understanding of javascript basics: I've been using the following method to create an object array of variables: $.searchfunction = { searchbox: $('#searchinput'), url: 'http://localhost', targetdiv: $('#results'), specifierobj: {}, keyboardid: '#keyboard' }; I'm having trouble with getting the value of $.searchfunction.searchbox. I'm calling it in the following manner: var curval = $.searchfunction.searchbox.val(); This isn't working--I tested this attempt with val() in Firebug and it does not work. I've noticed that if I type in $('#searchinput') in Firebug, the object is different than $.searchfunction.searchbox. Respectively, $.searchfunction.searchbox; Object length=0 context=document selector=#searchinput $('#searchinput'); Object 0=input#searchinput length=1 context=document I know there are jQuery objects and other types of objects, so I am assuming it is a problem with this but I don't understand why the variable does not store the #searchinput in the same manner. Thanks for any help.
[jQuery] Re: array problems
In PHP, monster[pid][id2]['db_id'] will create the intermediate arrays (monster[pid] and monster[pid][id2]) if they don't already exist. Javascript isn't that smart, and monster = [[[]]] doesn't help. You'll have to do something like: monster[pid] = monster[pid] || []; monster[pid][id2] = monster[pid][id2] || {}; // I'm using {} rather than [] since you're using a string to access it, not a number monster[pid]pid2]['db_id'] = $(this).find('db_id').text(); Inconvenient, but I don't know a way around it. On Mar 29, 12:04 pm, Tadas J [EMAIL PROTECTED] wrote: Hello, I have a problem with arrays. I am getting data from xml and trying to get data to arrays. Here is my code: === var monster = [[[]]]; ... $(this).find('monsters').each(function(id2){ monster[pid][id2]['db_id'] = $(this).find('db_id').text();}); ... === When I am alerting the variable it alerts only the first value and then stops and in firebug I see this error: monster[pid][id2] has no properties [Break on this error] monster[pid][id2]['db_id'] = $ (this).find('db_id').text(); Maybe I have wrongly defined monster variable?
[jQuery] Re: Safari not rendering styles loaded though ajax
Technically, Safari is doing it right (but it's very frustrating). style elements can only go in the head, not the body. As far as I can tell, there's no reason for this rule and HTML5 will allow it, but XHTML does not. So Safari throws out the style elements that you are trying to append to the body. My solution was to separate out the style element as a .css file, and include it in the head: $('link type=text/css media=screen rel=stylesheet href=/css/ whatever.css').appendTo('head'); Danny On Mar 9, 3:23 pm, rernens [EMAIL PROTECTED] wrote: We extensively use jquery in conjunction with our proprietary CMS for building web site and web application. We use jquery 1.2.3 and face a problem only in Safari 3. Styles injected with pages loaded through ajax seem not recognized and as a result pages a not properly rendered. Works just fine in all other browsers that we tested (IE7, Firefox 2 (windows and MacOS x, Opera 9 (windows and MacOS X). http://immo.web-a-la-carte.comis a good example. Go to the société tab and look at the form in the bottom left of the page. The form is rendered properly in Firefox and other browsers listed above but not in Safari 3. The form is dynamically generated and loaded with ajax with the associated styles and javascripts. Has anyone an idea why css injected this way is not properly handled by safari. Help appreciated.
[jQuery] Re: Xpath and length() doesn't seem to work under IE7?
Isn't length a property, not a function (use $(...).length, not $ (...).length() ) On Mar 6, 10:12 am, Yansky [EMAIL PROTECTED] wrote: This isn't a problem as such, just something I'm curious about. Under IE7 I've found that when I use xpath, the length() method doesn't seem to work, but size() does. E.g. $( '//[EMAIL PROTECTED] indexL2]//a').length(); doesn't seem to work, but $ ( '//[EMAIL PROTECTED] indexL2]//a').size(); does. I was just wondering why that is? Is it something to do with the fact that the xpath has to be converted to regular DOM getters for IE in the jquery code?
[jQuery] Re: Plugin Authoring Help pt 2
By the way, you'll have trouble if you use defaults like this: $.fn.myPlugin1 = function(options) { var myOptions = $.extend(defaults, options); since that will actually extend the defaults object and your defaults will be changed whatever was in options for the next time you use the plugin. Try $.fn.myPlugin1 = function(options) { var myOptions = $.extend( {}, defaults, options); which creates a new object to accumulate the options. Danny On Mar 4, 2:13 pm, Mike Alsup [EMAIL PROTECTED] wrote: If you want to use two different functions in the chain then you need to define two plugin functions: // wrap it all in a closure so you can share private data easily (function() { $.fn.myPlugin1 = function(options) { var myOptions = $.extend(defaults, options); // do stuff }; $.fn.myPlugin2 = function(options) { var myOptions = $.extend(defaults, options); // do stuff }; var defaults = { def1: 'default1', def2: 'default2', ... defx: 'defaultx' }; })(); On Tue, Mar 4, 2008 at 2:09 PM, Leanan [EMAIL PROTECTED] wrote: Ok, I'm really trying to wrap my head around this, and it's irritating me. I've checked out the following pages: http://docs.jquery.com/Plugins/Authoring http://www.learningjquery.com/2007/10/a-plugin-development-pattern And they help some but there's one problem I'm running into. I have: $.fn.myPlugin = function(options) { $.myPlugin.defaults = $.extend($.myPlugin.defaults, options); return(this); }; $.myPlugin = { defaults: { def1: 'default1', def2: 'default2', ... defx: 'defaultx' }, myFunc: function() { var options = $.myPlugin.defaults; //do something here, anything really }, myFunc2: function() { var options = $.myPlugin.defaults; //do something here, again, anything } }; Now, I want to do something like this: jQuery().myPlugin({def1: 'other_def1', def2: 'other_def2'}).myFunc(); Can I? Because it's not working. It tells me that jQuery().myPlugin({def1: 'other_def1', def2: 'other_def2'}) is not a function. However, if I change it so that myFunc is $.fn.myFunc = function() { }, then I can, but I have to do it as: jQuery().myPlugin({def1: 'other_def1', def2: 'other_def2'}).myPlugin.myFunc(); Which I don't like. None of the tutorials or documentation I can find is clear on this point, though they do refer to the functions in $.myPlugin as being user-accessable... and they are, but only if I do $.myPlugin.myFunc. I can't chain. And I want to be able to do that.
[jQuery] Re: Change stylesheets if images are off
Unfortunately, no. You can't tell whether a .load will fail until it does fail, and that's true of any asynchronous method. You can't say if it's failed or just not succeeded yet. All you can do is set a time limit and check if you've succeeded in that time and if not, assume you've failed. That's why $.ajax has timeout and error options. In your example, you can do var timeout = 1000; // milliseconds var success = false; $(animage).load(function(){ success=true; do_success_things(); }); setTimeout(function(){ if (!success) do_fail_things(); }, timeout ); I haven't found any way of directly asking the browser if images are enabled, so I think you're stuck with this. Danny On Feb 17, 6:41 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Yet another question about this (or perhaps about Javascript in general) ... Am I missing something that's staring me in the face, or is it really not possible to make a function that goes something like jQuery.fn.afunction(animage) { if ! $(animage).load(function() { . do stuff because we're not loading images ... that is, an if not function ? I'm very perplexed.
[jQuery] Re: Change stylesheets if images are off
A simple hack to detect if images are enabled: Include the following in your HTML: img src=http://microsoft.com/nothing.gif; onerror=alert('hello'); style=position: absolute;top=-100px / If images are enabled, we waste microsoft's bandwidth for a bit (it could be any nonexistent image file on any server, obviously), and the browser executes the onerror function (which should do something more sophisticated than alert; it could change your stylesheet, for instance). If images are not enabled, the function is not executed. The style attribute is there just to hide the ugly red x in IE, but setting it really invisible with display: none or visibility: hidden tells the better browsers (Opera) not to bother getting the image, so the error function never gets called. This was tested in Firefox 2, IE 6, Opera 9, Safari 3 Using jQuery to insert the element, with $('img src=http://microsoft.com/nothing.gif; onerror=somefunc() / ').appendTo('body') works as well. Danny
[jQuery] Re: Change stylesheets if images are off
One thing I realized, is that it will still have a delay from page load to running the images-enabled function--the browser has to request the nonexistent image, get the 404 Not Found response, then execute the onerror. So you may well have a flash of 'noimages.css' before 'gotimages.css' are loaded. The fastest thing may be to use http://localhost/nothing.gif; as your non-image. Danny On Feb 16, 11:15 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: OMG, I can't wait to test this!!!
[jQuery] Re: Most basic of basic fundamental questions.
This is a critical point to get to use Javascript effectively. The line $('.poem-stanza').addClass('emphasized'); by itself is executed as soon as the interpreter gets to it. function(){ $('.poem-stanza').addClass('emphasized'); } doesn't execute the addClass; it just creates a function that can be executed later It's just like writing, somewhere else in your code: function someFunction() { $('.poem- stanza').addClass('emphasized'); } except that the first function doesn't have a name (it's anonymous). It still can be assigned to a variable or passed as an argument. So: $(document).ready(function() { $('.poem-stanza').addClass('emphasized'); }); creates an anonymous function and passes it to the $(document).ready function, and $(document).ready keeps the reference to that function around until the document is in fact ready, then executes it. But: $(document).ready( $('.poem-stanza').addClass('emphasized'); ); does the $('.poem-stanza').addClass('emphasized'); immediately: it finds all elements with class 'poem-stanza' which probably is nothing since your script element is probably in the head, before any of the body elements have been created, adds the class to whatever it found and passes those elements (not a function!) to $(document).ready. $(document).ready expects to get a function, not a jQuery object of HTML elements, and will probably throw an error. I think Javascript 2 will have a more elegant way of expressing a block of code to be stored and executed later but for now we have to use function(){...} HTH, Danny On Feb 5, 9:30 am, Pickledegg [EMAIL PROTECTED] wrote: I'm reading 'learning jQuery'. In this example, and in fact every example, why do you pass a function as an argument. $(document).ready(function() { $('.poem-stanza').addClass('emphasized'); }); why can't I do this? $(document).ready( $('.poem-stanza').addClass('emphasized'); ); Thanks. I'm asking this a learning exercise, so I apologize in advance for the apparent stupidity of it.
[jQuery] Re: Problem with siblings(?) in IE6
Yes--IE6 creates global variables for every element with an id or name, and won't let you overwrite them. I didn't realize that IE7 fixed that. You could also have solved your problem by putting 'var' before the variable names--declaring them as local to the click function. Probably a good idea anyway--you hate to mess up the global namespace. Danny On Feb 1, 4:00 am, Michael Price [EMAIL PROTECTED] wrote: Given the following table cell: td input class=SearchProdID type=hidden value=460 name=ProdID/ input class=SearchQty type=text value=1 size=2 name=qty/ input class=cartadd type=button value=+ name=searchcartadd/ /td The following JavaScript works in FF2 and IE7 but not in IE6: $(.cartadd).click(function() { // GET SIBLING PRODUCT IDS IDBox = $(this); ProdID = $(this).siblings(.SearchProdID).val(); Qty= $(this).siblings(.SearchQty).val(); alert(Here); // MORE CODE } In FF2 and IE7 Here is alerted and the entire function (which later posts these variables via AJAX) runs perfectly. In IE6 I don't get the alert. If I alert IDBox right after the line where it's set, I get [object Object] which I believe is correct, but as soon as it hits the next lines involving siblings, it just stops dead - no error, no warning, nothing. Following up to my own post but while I was waiting for my post to appear in the group I decided to try changing the variable name from ProdID to ProductID - and it worked! A near identical piece of code was having a similar problem so I changed the variable from SeriesName to SeriesID - and that fixed the problem there too! My theory here is that if you look at the above snippets, the hidden form elements in both cases had the names ProdID and SeriesName, so they were already defined as variables and IE6 had a problem with overwriting or reassigning them somehow? Regards, Michael Price
[jQuery] Re: Appending/prepending image source attribute
I think you would want to append just the ampersands, not 'amp;' that's only to get the href past the HTML parser. Thus: $('someImage').attr('src', '/umbraco/ImageGen.aspx?image=' + originalSrc + 'width=' + width + 'height=' + height); Danny On Jan 31, 10:05 am, Karl Swedberg [EMAIL PROTECTED] wrote: Hi Ove, I think you sent me an email over at learningqjuery.com, but I'll answer here for the record. it would go something like this: var height = $(#myElement).height(); var width = $(#myElement).width(); var originalSrc = $('someImage').attr('src'); $('someImage').attr('src', '/umbraco/ImageGen.aspx?image=' + originalSrc + 'amp;width=' + width + 'amp;height=' + height); --Karl _ Karl Swedbergwww.englishrules.comwww.learningjquery.com On Jan 31, 2008, at 6:45 AM, Azzlack wrote: I am trying to change the source of an image when the page loads to include some code in front, and after the url. Like this: Original src: http://www.teamviewer.com/images/teamviewer.png How I want it to look like: /umbraco/ImageGen.aspx?image= + (original-src) + amp;width= + width + amp;height= + height; height = $(#myElement).height(); width = $(#myElement).width(); Regards, Ove Andersen
[jQuery] Re: Fighting a closure
Depends on what you're trying to do. In your case, the index and the value are identical, but next time they may not be: $.each( ['a','b','c'], function (index, val){ // index is 0...1...2, val is 'a'...'b'...'c' }); On Jan 31, 3:40 pm, timothytoe [EMAIL PROTECTED] wrote: $.each( [0,1,2,3,4], function(index, num) { $(#port+num).click(function() { bigchart(num); }); }); Wait. What's the index in there for. I don't need that, do I? Seems to work fine without it. I'll assume that was a leftover from a previous idea.
[jQuery] Re: Is this the best way?
jQuery does not have a built-in selector to compare the values of attributes, but it allows you to write custom filters (analogous to plugins). I once found documentation on this but can't anymore. You sort of have to read the source to learn to do this. You just extend the $.expr[':'] object with your new filter set to a string that is evaluated, where 'a' is the element being tested and 'm[3]' is the argument to the filter: $.expr[':'].levelGreaterThan = '$.attr(a,level)m[3]' ; Now you can use this anywhere: $('qualif:levelGreaterThan(3)').remove(); Far more bizarre but potentially useful would be a custom filter that tests any attribute: $.expr[':'].attr = 'eval(m[3].replace(/^(\\w+)/,$.attr(a,\\$1\ \)))'; and now write: $('.qualif:attr(level3)').remove(); Unfortunately the parser for [attr] is not extensible, so you can't create a [level3] selector directly Danny On Jan 30, 12:22 pm, Feijó [EMAIL PROTECTED] wrote: Hi Cabbite Thanks for your 0.02 Its possible to simple use like this? $('.qualif[level3]').remove(); if level bigger then 3, remove it :) My code is dynamic, I cant just wrote all numbers I dont need to remove, like your example. Has to use a condition. Feijó cabbiepete escreveu: Hi Felix, I would have thought doing an attribute selector like you suggest was better. something like ... $('.qualif[level]).each ... to at least get rid of anything that doesn't have the level attribute. Also if you use the same tag name for all of these attributes its worth adding that as it also helps with efficiency, i.e. jquery only has to check those tags for level attribute. Depending on the exact use of the level attribute you might be able to get just the ones you want by using [attribute!=value] selectors. i.e. if you want greater than 4 and start at 0 $('.qualif[level!=0], .qualif[level!=1], .qualif[level! =2], .qualif[level!=3], qualif[level!=4]').remove(); Hope that helps. Also if any more expert on jquery knows more am keen to know better also. Cheers, Pete On Jan 30, 12:56 pm, Feijó [EMAIL PROTECTED] wrote: Hi, I was just wondering if there is any better way to accomplish that. Some divs has 'level' attribute, with a number. If that number is bigger than X, will remove the div. var x=4; // simulating level=parseFloat($this.attr('level')); $('.qualif').each(function() { if ($(this).attr('level')x) $(this).remove(); }); I don't know if we can set a filter in $('') to look at a custom attribute, should be simpler than Feijó
[jQuery] eval vs. Function
A question for the jQuery team: I look at the jQuery source code as my source for Javascript best practices, and I see a few examples of things like: fn = eval(false||function(elem){return + fn + }) What is the advantage of that over using Function, as: fn = Function('elem', 'return '+fn) which seems to do what you want more clearly and concisely.
[jQuery] Re: Callback-return into global variable
$.getJSON and all the AJAX functions are asynchronous; the function returns before it gets any result. That's why there's a callback function: it gets called when the data are available. So when you write load_comments(); $.each(_json.comments, function(comment) { load_comments() just sets up the AJAX call and returns, so the each starts with _json not yet initialized. You can get around it by using asynch: false in a $.ajax call (see the documentation), but that's not the ideal solution. Better to put your $.each into the callback function: $.getJSON(paths.get_comment, _params, function(data) { $.each (data.comments, function (comment){...}) }); Danny On Jan 16, 1:17 am, Niels [EMAIL PROTECTED] wrote: Is there any way to put a return from within a callback into a global variable? I'm trying to retrieve JSON-values in one statement, and output them in another statement; and code looks like this: var _json; function load_comments(id, params) { if (typeof id != 'number' typeof id == 'object' params == null) { // Only the params were specified. _params = process_params(id); $.getJSON(paths.get_comment, _params, function(data) { _json = data; return _json; }); console.info('1 : $.getJSON(' + paths.get_comment + ', ' + _params + ')'); } } function display_comments() { load_comments(); $.each(_json.comments, function(comment) { $(#recent-comments-list).append(li + comment.content + / li); }); } Unfortunately, _json seems to remain undefined... What am I doing wrong? Or is there really no way to accomplish this? Thanks a lot! Niels
[jQuery] Re: submit via link and redirect dynamically
I'm not an AJAX guru, but it looks like the pageNumber variable is local to each of your click functions and won't be seen by the showResponse function. Make it global (actually, local to the document.ready function): $(document).ready(function(){ var pageNumber; // local variable in this document.ready function ...other stuff.. function showResponse(responseText, statusText) { $(body).addClass(curAuto); $('div#adv_content').load('inc/de.application.adv.inc.php? page='+pageNumber); // showResponse doesn't have its own pageNumber variable, so it uses the enclosing function's one. This is called a closure. } $('#step1').click(function(){ pageNumber = '0'; // note: no 'var' ! So no local pageNumber variable, so it uses the enclosing function's one. The same one that showResponse will use later! A little bit of Javascript magic. $('#myform').ajaxSubmit(options); return false; }); On Jan 13, 2:47 am, antiheld2000 [EMAIL PROTECTED] wrote: hi, i'm developing a little site, where the user has the possibility to fill in several forms. i want that the user can navigate through those forms via normal html links. on click the form should be submitted and on success the content in div #xy be updated in relation to the link. i tried it like this, but this is not working. has anybody a workaroung or else? thank you anti my try: $(document).ready(function(){ var options = { beforeSubmit: showRequest, success: showResponse, url: 'inc/application.adv.func.php' }; function showRequest(formData, jqForm, options) { $(body).addClass(curWait); var queryString = $.param(formData); return true; } function showResponse(responseText, statusText) { $(body).addClass(curAuto); jQuery('div#adv_content').load('inc/de.application.adv.inc.php? page='+pageNumber); } $('#step1').click(function(){ var pageNumber = '0'; $('#myform').ajaxSubmit(options); return false; }); // etc. etc. $('#step5').click(function(){ var pageNumber = '4'; $('#myform').ajaxSubmit(options); return false; }); })
[jQuery] Re: htmlspecialchars($string) equivalent
function htmlspecialchars(string) = { return $ ('span').text(string).html() } the text() function does what you want but only by inserting the string into an element. html() pulls it back out. Danny On Jan 10, 5:18 pm, acesfull9 [EMAIL PROTECTED] wrote: is there a javascript/jQuery equivalent to htmlspecialchars($string) in PHP
[jQuery] Re: Cross domain POST
To the best of my knowledge, cross domain script loading is just as much a security risk, but it was present in browsers before the risks were realized and too many sites depend on it, so no one can remove it. It's a historical anomaly. Danny On Jan 9, 9:39 am, Miha [EMAIL PROTECTED] wrote: Now I have another question? From the security point of view, what is the difference between cross domain script loading and cross domain ajax requests? Why script loading is permitted by browsers and ajax is not? regards, Miha
[jQuery] Re: Using one namespace for multiple methods
The short answer is, yes, you're doing the wrong thing to try to namespace plugins. It's not officially supported. If you really want to, I wrote a small plugin that simulates namespaces by copying methods in and out of the jQuery object; it was discussed here: http://www.nabble.com/Re%3A-passing-this-p13540912s27240.html Danny On Jan 9, 12:29 pm, Zoram [EMAIL PROTECTED] wrote: I am working on a plugin and was trying to figure out what was happening to break my code.. I have in my plugin functions similar to the following: $.fn.pluginName = function() {} $.fn.pluginName.oneThing = function () { ... } $.fn.pluginName.anotherThing = function () { ... } I try to call it like so: $('#idOfElement').pluginName.oneThing(); The problem is that the this.each() is 'not defined' when I use it in the oneThing or anotherThing methods. If I do the methods as: $.fn.oneThing and $.fn.anotherThing it works fine... but not when they are under the pluginName. Why would this happen and is there a way to fix it? or am i trying to do the wrong thing tonamespacethe methods? Thanks in advance.
[jQuery] Re: append ul (unordered list) ie bug
It looks like you've got some syntax errors. In the first example, ul id=c-rply-to'+id+'/ul is missing a double quote: ul id=c-rply-to'+id+'/ul (that's a single quote followed by a double right after id+ In the second, #('#c-r+id) should be $('#c-r'+id) See if that works Danny On Jan 6, 4:28 pm, chrismarx [EMAIL PROTECTED] wrote: in firefox this works fine var id = 1; $parent.append('div id=c-r'+id+' class=c-replies c-hide style=display: none;ul id=c-rply-to'+id+'/ul/div'); but in ie, no ul gets created. next i tried appending the ul to the newly created div (and yes, the div was found) var id = 1; $parent.append('div id=c-r'+id+' class=c-replies c-hide style=display: none;/div'); #(#c-r+id).append(ul/ul); that didnt work either. i had to resort to this var iediv = document.getElementById(c-r+id); var newElem = document.createElement('ul'); newElem.id = c-rply-to+id+; iediv.appendChild(newElem); can someone spot the problem?
[jQuery] Re: Chaining methods and Debugging?
I'm not a Firebug expert, but this seems to work: $.fn.log = function (brk){ console.log(this); if (brk) debugger; return this; }; So now $(...).log() puts the jquery object on the console and .log(true) also drops into the debugger (equivalent to setting a breakpoint). I'm not sure how to add a value to the watch list; when I use the above plugin 'this' and 'brk' are on the watch list but they go out of scope when it returns Danny On Dec 28, 2:59 pm, Mike Schinkel [EMAIL PROTECTED] wrote: Danny wrote: For quickie debugging to FIrebug, you could define $.fn.log = function { console.log(this); return this;}; and now you've got a chainable log that you can put anywhere in the chain: $('p').log().css('color', 'red').log().slideDown() etc. I haven't tested this (I'm sitting in front of IE 7) but it ought to work. Nice. Anyone know if there is a way in code to trigger a Firebug breakpoint and also add a value to the watch list if it isn't already there? -- -Mike Schinkelhttp://www.mikeschinkel.com/blogs/http://www.welldesignedurls.orghttp://atlanta-web.org
[jQuery] Re: Chaining methods and Debugging?
For quickie debugging to FIrebug, you could define $.fn.log = function { console.log(this); return this;}; and now you've got a chainable log that you can put anywhere in the chain: $('p').log().css('color', 'red').log().slideDown() etc. I haven't tested this (I'm sitting in front of IE 7) but it ought to work. Danny On Dec 27, 9:47 pm, Mike Schinkel [EMAIL PROTECTED] wrote: Is there a particular problem that you are trying to debug? No, it just seems the pattern I find for practically every debug session I encounter, both for Javascript/jQuery and for Drupal/PHP development. In the beginning, I would put console.log in the callbacks (if the method had one) and that allowed me to see when one thing was be executed. Sorry for being dense here, but I don't follow this? (BTW, I'm much more comfortable developing sql-based server apps; I've just ventured into developing browser-based apps.) Another tip that should probably help, instead of doing. $('p').css('color','red').slideDown().css('font-weight', 'bold'); do: $('p') .css('color','red') .slideDown() .css('font-weight', 'bold'); Interesting; that never would have occured to me. Thanks for suggesting it? Will Firebug stop on every line (yes I could test, but I'm about to be off to bed so I figured I'd just ask...)? How can I see the intermedia results? This, to me, makes it a little more human readable and easier to comment out a line. Definitely. Thanks. -- -Mike Schinkelhttp://www.mikeschinkel.com/blogs/http://www.welldesignedurls.orghttp://www.welldesignedurls.org/ http://atlanta-web.orghttp://atlanta-web.org/
[jQuery] Re: LavaLamp for jQuery 1.2.x?
Hi Andy: Erland Schei gave you the answer; the names of the easings changed from the time lavalamp was originally written. Look at http://gsgd.co.uk/sandbox/jquery/easing/ for the correct names. easeOutBack is the classic effect. Danny On Dec 13, 8:29 pm, Andy Matthews [EMAIL PROTECTED] wrote: FYI Danny... I put your change in place, downloaded the most recent versions of both jQuery (jquery-1.2.1.pack.js), and Easing (jquery.easing.1.3.js) and now each time I mouseover a button I get about 100 js errors, all saying: E.easing[this.options.easing || (E.easing.swing ? swing : linear)] is not a functionhttp://localhost/downloads/lavalamp/jquery-1.2.1.pack.js Line 11 Any ideas? On Dec 12, 11:25 pm, Danny [EMAIL PROTECTED] wrote: I modified it to run under 1.2, with the most recent easing plugin:http://youngisrael-stl.org/inc/jquery.lavalamp.js On Dec 12, 10:21 pm, Andy Matthews [EMAIL PROTECTED] wrote: I'm really wanting to use Ganeshki's excellent LavaLamp plugin (http://www.gmarwaha.com/blog/?p=7) but it appears that it doesn't work with the most current stable release of jQuery. Does anyone know if there's an updated release somewhere that meets the 1.2.x requirement? Or is there an alternate menu which gives the same effect?- Hide quoted text - - Show quoted text -
[jQuery] Re: Object architecture problem.
If you have no reason to chain your plugin (something like $ ('#photo').photo(...).css(...).attr(...) then having it return a different object makes sense. But then, why put it in the jQuery namespace at all? 'return new smaon.photo(...) makes as much sense. Danny On Dec 12, 10:38 am, Smaon [EMAIL PROTECTED] wrote: Thank you for your answer Danny. I'm currently trying this way: jQuery.fn.photo = function (...) { var canvas = $(this).get(0); return new jQuery.photo(canvas, settings); } jQuery.twistMap = function(canvas, settings){ //create code this.crop = function(){ .. } } usable like this: var photo = $(#photo).photo(...); photo.crop(); What do you think? For me, while not being perfect, it seems more or less ok... PS: BTW, it there a way to put clean code in this discussion group?
[jQuery] Re: Object architecture problem.
I actually agree strongly with you: plugins should be chainable. But not all are (even some jQuery methods are not, like the ones that return text [val(), html() etc. without arguments]). On Dec 12, 9:47 pm, Brian Cherne [EMAIL PROTECTED] wrote: I want to disagree with Danny's first statement... if you're going to create a jQuery plug-in (re-usable and useful to all) then it's best to follow the convention of returning the elements it's acted on. If you want it to return something else (or nothing) don't create a plug-in -- instead create a separate global object w/methods. I haven't time to write the innards of the plug-in approach, but I'd recommend a syntax like: $('#photo').photo( method, settings ).css(...).attr(...); var createSettings = { src:uri }; var cropSettings = {width:w,height:h}; $('#photo').photo( 'create', createSettings ).photo( 'crop', cropSettings ).show(); Chaining is one of the most powerful features of jQuery... let it work for you! Brian. On 12/12/07, Danny [EMAIL PROTECTED] wrote: If you have no reason to chain your plugin (something like $ ('#photo').photo(...).css(...).attr(...) then having it return a different object makes sense. But then, why put it in the jQuery namespace at all? 'return new smaon.photo(...) makes as much sense. Danny On Dec 12, 10:38 am, Smaon [EMAIL PROTECTED] wrote: Thank you for your answer Danny. I'm currently trying this way: jQuery.fn.photo = function (...) { var canvas = $(this).get(0); return new jQuery.photo(canvas, settings); } jQuery.twistMap = function(canvas, settings){ //create code this.crop = function(){ .. } } usable like this: var photo = $(#photo).photo(...); photo.crop(); What do you think? For me, while not being perfect, it seems more or less ok... PS: BTW, it there a way to put clean code in this discussion group?
[jQuery] Re: Object architecture problem.
It sounds like you want a way to create namespaces for plugins. There isn't an official way, but I wrote a small function to create namespaces that was discussed on a previous thread: http://www.nabble.com/Re%3A-passing-this-p13540912s27240.html Also, it looks like your functions jQuery.Photo.create are actually meant to be plugins (i.e. they refer to 'this' as a jQuery object) so they should not be part of the jQuery object itself. Just do jQuery.fn.extend ({ photocreate: function(settings){ }, photocrop: function(...){ } }); Or, if using my namespace plugin, $.namespace ('photo', { create: function(settings){ }, crop: function(...){ } }); Danny On Dec 11, 6:43 pm, Smaon [EMAIL PROTECTED] wrote: Hi everybody, ok, I'm in a big trouble right now. Let me try to explain my problem :) I'm trying to create a simple photo editing system. I need to define a DIV as the canvas, then to have many methods applicables to this object. My first reflex was to create a jQuery extension, something like this (just to give the idea): jQuery.Photo = { create: function(settings){ }), crop: function(...){ } }; jQuery.fn.extend( { Photo: jQuery.Photo.create, crop: jQuery.Photo.crop }); Very well, now I was able to create my editable photo by using $ (#photo).Photo() and to crop by using $(#photo).crop() BUT, the problem is that I need to extend jQuery with every method I want to use on my photos. For example crop() is now in the global scope, and this is very ugly. To do well I should name it PhotoCrop, but this I don't find it's a good solution. What I would like is to have methods only usable on instances of the Photo object, in its local scope. For ex, in core javascript it would be like that: function Photo(){ ... } Photo.prototype.crop = function(){ ... } The problem is that I don't find any way to do this properly with jQuery. Maybe somebody here could help me? Many thanks in advance! Smaon
[jQuery] Re: A 5 line script that doesn't work in IE
The answers given here (use is and addClass and removeClass for element classes) are correct, but the more general problem is using reserved words in objects. You can always quote them and they'll work: { class: 'foo', for: 'foo', function: 'foo' } all fail, but { 'class': 'foo', 'for': 'foo', 'function': 'foo' } are fine On Dec 1, 6:14 pm, Gordan [EMAIL PROTECTED] wrote: I'm loosing my mind over this :-(http://www.writesomething.net/users/(show classical users list link) I have a few lines of code which are extremly simple and work as expected in FF, but IE is refusing to cooperate :-( I tried literally everything but it just returns the expected identifier, string or number error. Please help, this has to be some simple bug that I'm overseeing :- ( thank you here's the complete code, and I use the latest 1.2.1 jQuery: (IE says that the error is on the 3rd line) function change_users_display() { if ($('#users').attr('class') == 'users_cloud') { $('#users').attr({class: ''}); $('#change_users_display_classical').show(); $('#change_users_display_cloud').hide();} else { $('#users').attr({class: 'users_cloud'}); $('#change_users_display_classical').hide(); $('#change_users_display_cloud').show(); } return true; }
[jQuery] Re: Animating from one CSS class to another
This was an old post, but if you're still interested I've been thinking about a CSS parser with Andy Kent (for jss). It reads all the stylesheets and style elements and assembles them into one large JSON. It's at http://youngisrael-stl.org/wordpress/blogfiles/cssparser/cssparser.jquery.js and if you include it you can do: var style = $.parsecss()['.myclassname']; if (style) $('#widget').animate(style); Unfortunately animate throws an error if style is undefined, so it needs the guard condition. Let me know if this is helpful. Danny On Nov 3, 10:12 pm, S. Robert James [EMAIL PROTECTED] wrote: I have a animation using jQuery, which goes from one position to another. Right now, the positions are coded into JavaScript: $(#widget).animate({top: '500px'}) Instead of hard-coding 500px into JavaScript, or even passing it as a parameter, I'd much rather set them in CSS, and run the animation from that. That keeps all the design layout together, and allows identical JavaScript to work with both of them. Something like: #widget.down { top: 300px;} #widget.up { top: 500px;} $(#widget).animate({class: 'up'}) Any jQuery hacker's have a suggestion on how to do something like that? Is it possible to read the values off of the CSS stylesheet? (In general, what's everyone's opinion about this method. I think it's a lot cleaner, keeping cohesion up and coupling down...)
[jQuery] Re: Defining and using of JSON defaults/options
I believe the syntax is (not tested): $(e).parent().next()[utoggle.animationType](uToggle.speed); Javascript objects are associative arrays. Danny On Nov 1, 3:29 am, Olaf Gleba [EMAIL PROTECTED] wrote: Little Correction for the second example (needless '()' in chain). Am 01.11.2007 um 09:22 schrieb Olaf Gleba: Example (doesn't works): var uToggle = { animationType: 'fadeIn', speed: 'fast' ... xxx: function(e) { $(e).parent().next().uToggle.animationType()(uToggle.speed); } }; ... xxx: function(e) { $(e).parent().next().uToggle.animationType(uToggle.speed); ... -- Olaf Gleba : creatics media.systems tel. +49 (0)212 38 32 94 30 : fax. +49 (0)212 38 32 94 31 [EMAIL PROTECTED] :http://www.creatics.dehttp://www.creatics.de/keys/
[jQuery] Re: Is it possible to alter internal CSS properties?
You can manipulate stylesheets, though it's not pretty (or built-in to jQuery; you could write plugins to do it). See http://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript On Nov 1, 4:24 am, Jesse Klaasse [EMAIL PROTECTED] wrote: As we all know, we can do the following using jQuery: $('.someClass').css(background-color: yellow); This first matches all elements which have the class someClass, and then alters the css of the matched elements. This won't work when the class is dynamically added somewhere in the page, for example on a mouseover. Is it somehow possible to really alter the internal style sheet definition, in order to reflect the wanted changes when a class is dynamically added? My guess is that this is not possible at all, but I'm not sure.. Any ideas? Thanks!
[jQuery] Re: Is it possible to alter internal CSS properties?
I actually wrote a plugin that may be helpful (worked with jQuery 1.1, Firefox and Internet Explorer. I haven't updated it since) See http://www.nabble.com/Creating-stylesheets-in-jQuery-tf3298905.html#a9176651 Lets you write $.style('.someClass').css('background-color', 'yellow'); On Nov 1, 5:17 pm, Danny [EMAIL PROTECTED] wrote: You can manipulate stylesheets, though it's not pretty (or built-in to jQuery; you could write plugins to do it). Seehttp://www.hunlock.com/blogs/Totally_Pwn_CSS_with_Javascript On Nov 1, 4:24 am, Jesse Klaasse [EMAIL PROTECTED] wrote: As we all know, we can do the following using jQuery: $('.someClass').css(background-color: yellow); This first matches all elements which have the class someClass, and then alters the css of the matched elements. This won't work when the class is dynamically added somewhere in the page, for example on a mouseover. Is it somehow possible to really alter the internal style sheet definition, in order to reflect the wanted changes when a class is dynamically added? My guess is that this is not possible at all, but I'm not sure.. Any ideas? Thanks!- Hide quoted text - - Show quoted text -
[jQuery] Re: doc type error when using corner plugin
I always get error when the server returns my 404 (page not found) error page instead of the javascript file. Make sure the script file with that name exists; I suspect you really want 'jquery.corner.js' (standard way to name plugins) rather than 'jquery- corner.js' On Oct 31, 11:24 pm, iain duncan [EMAIL PROTECTED] wrote: Hoping someone who knows about doctypes can help me out here. I am using kid templates with turbogears, so my html file has the following as it's first line. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; Using Jquery and the jquery calendar plugin have been no problem, and I am also using MochiKit without problems. However, when I add in the jquery corner plugin I get this error: syntax error jquery-corner.js (line 1) !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; Any clues, much appreciated! Iain
[jQuery] Keepaway plugin-for the easily amused
I just got one of those gag surveys: Are you happy with your salary? where the No button runs away from the mouse. I figured I could use that on a web page someday so I wrote a simple plugin for it; see http://youngisrael-stl.org/wordpress/blogfiles/keepaway.html If there's any positive feedback I'll put it in the wiki.
[jQuery] Re: passing this
Interesting question. As far as I can tell (playing with things like $ (selector).(namespace.function)() and the like) it is not possible to namespace plugins. Danny On Oct 28, 5:50 pm, Jean-Sébastien [EMAIL PROTECTED] wrote: sorry, james i didn't see someone answer me. what i want to do is ('div').set_of_plugins.choosen_plugin(). where the first level (set_of_plugins) is kind of container (namespace) of all my plugins. is it possible to do it? On Oct 28, 5:20 pm, James Dempster [EMAIL PROTECTED] wrote: There is already a jQuery .parent() method. Not quite sure what your trying todo. But each method is run in the context of the selected elements. e.g. jQuery.fn.extend({ test: function() { return this.each(function() { // do something with elements }); } }); would do something with all the selected elements via test. $ ('div').test() /James On Oct 27, 8:49 pm, Jean-Sébastien [EMAIL PROTECTED] wrote: Hello, i want to call a function $('#selection').parent.child() with the following code : jQuery.fn.extend({ parent: { child: function(o){ doSomethingWith(selectedElement) } } }); but i dont know how to pass the selected element through parent (#selection) to child function. regards.
[jQuery] Re: Lookup doesn't work within HTML loaded with .load()
.load is asynchronous, which means that it returns (and the next statement is executed) before it finishes loading. So $(#left).load(test.html); starts loading #left with test.html but $(#left).css(border,1px solid red); executes within milliseconds, and test.html probably hasn't come back from the server yet. You need to use a callback ( http://docs.jquery.com/Ajax/load#urldatacallback ): $(#left).load(test.html, function(){ $(#left).css(border,1px solid red); etc. }); That ought to work! Danny Sagari-2 wrote: Greetings, I have a nasty surprise: jQuery (1.2.1) won't access DOM elements that have been inserted via .load() function. Example: index.html: --- !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN DTD/ xhtml1-transitional.dtd htmlheadtitleTest/title script type=text/javascript src=jquery.js/script script type=text/javascript src=test.js/script /headbody div id=left style=float: left; width: 30% Left /div div id=left style=float: right; width: 69% Right /div /body /html test.js: - $(document).ready(prolog); function prolog() { $(#left).load(test.html); $(#left).css(border,1px solid red); $(#test).css(border,1px solid green); $(#left #test).css(border,1px solid green); } test.html: - div id=test Test /div After I load the index.html, I expect to see the #left div containing the test.html content; with #left with red border and #test with green. However, #test has no green border; in fact, I can't at all address the newly loaded HTML part, as it were not exist at all. I tried two kidns of addressing (in the test.js above) with no effect. How can I address the HTMl loaded via .load() function? Thanks. All the best, Konstantin -- View this message in context: http://www.nabble.com/Lookup-doesn%27t-work-within-HTML-loaded-with-.load%28%29-tf4692256s27240.html#a13417814 Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] Re: .attr()
You don't even need to explicitly accumulate the result: $.fn.attrs = function(key, val) { if (val != undefined) return this.attr(key, val); return $.map(this, function(a) { return $(a).attr(key); }); }; Danny malsup wrote: Good catch, Jörn! You don't even need the explicit loop: jQuery.fn.attrs = function(key, val) { if (val != undefined) return this.attr(key, val); var a = []; this.each(function() { a.push($(this).attr(key)); }); return a; }; -- View this message in context: http://www.nabble.com/.attr%28%29-tf3673211s15494.html#a10269078 Sent from the JQuery mailing list archive at Nabble.com.