Re: [jQuery] New Forums
Well stated, Shawn. I wholeheartedly concur.
Re: [jQuery] class="{title:'test'}
This is utilizing the metadata plugin for jQuery. It handles that sort of stuff. Sent from my iPhone On Jan 20, 2010, at 3:34, fran23 wrote: I don't know how to handle class="{title:'test'} it's out of the mb.extruder plugin logo ... normally I assign a class (i.e. class="abc") and set "abc" via CSS .abc { ... } but I don't know what to do with class="{title:'test'} May anybody give an explanation or link where I can learn about it? thx fran -- View this message in context: http://old.nabble.com/class%3D%22%7Btitle%3A%27test%27%7D-tp27238929s27240p27238929.html Sent from the jQuery General Discussion mailing list archive at Nabble.com .
Re: [jQuery] how to get href value
$("a").attr("href");
[jQuery] .add() strange behavior?
Hi all... I've come across something that I think is a little odd, but I'm not sure if I'm just being dumb. Have a look at this: $(function() { var $div = $(""); var $divs = $(); $divs.add($div); console.log($divs.length); // == 0 $divs = $().add($div); console.log($divs.length); // == 1 }); Logic tells me that $divs.length should be 1 in both cases. I've tested this with 1.3.2 and 1.4 and they both do the same thing, with the exception that in 1.3.2 the $() call creates a jQuery object with the document object in it, so the numbers return 1 and 2 instead of 0 and 1. Any ideas? Cheers, Matt Parlane
Re: [jQuery] New Forums
I concur regarding mailing list vs. forum. Both have their positives and negatives, but these days I definitely prefer a mailing list over forums. Perhaps the jQuery team could not find another mailing list that would import all of the existing posts on Google Groups? (My understanding is that they were able to do just that with the new forums.)
[jQuery] New Forums
Hello, I received an email inviting me to join the new jQuery forums. It contained a username and password for me to use. However, when I try to login, I am told that my email address has not been confirmed and therefore cannot do so. A link to a help page is given whereby I can allegedly have a confirmation email sent by following a list of instructions. Interestingly enough, the very first step given in the instructions is to login. I thought that perhaps I would be able to do so at the link given, but alas an attempt to login there results in the exact same message and help link being presented. Any suggestions on how to actually login/activate would be appreciated. :-)
Re: [jQuery] Re: Link Clicks Double Firing
That is true, but if you remove the link's href, the application will not degrade for users without JavaScript enabled. On Thu, Jan 14, 2010 at 8:46 AM, bill wrote: > this really an interesting jq/html semantic issue: if the tag is > not handling the actual redirection to another page, maybe we > shouldn't be using the tag at all. maybe the href should really > just be stored in the jq routine. this clears up maintenance issues > and passes the gut check. > >
Re: [jQuery] Re: What is the proper way to write this if statement?
You're right. This was a small oversight on my end, though, it would have been a little more helpful to the OP if you had provided an explanation with your reply. :) The reason I use var that = this; is not for scope but rather to ensure that the proper object is being referenced inside the function. Thanks, Matt On Wed, Jan 13, 2010 at 7:12 PM, RobG wrote: > > > On Jan 14, 11:00 am, Matt Maxwell wrote: > [...] > > var that = this; // scope > > The value of the this keyword has nothing whatever to do with scope. > > > -- > Rob >
Re: [jQuery] Plugin design pattern (common practice?) for dealing with private functions
Also, more information on the call function (if you're not familiar with it) can be found here: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function/call <https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function/call>You could also use the apply function: https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function/apply <https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Function/apply>If you need any other help with that or don't understand my example, let me know. Thanks, Matt On Wed, Jan 13, 2010 at 7:04 PM, Matt Maxwell wrote: > Maybe try using something like: > > $.myplugin.fill.call( this, "red" ); > > On Wed, Jan 13, 2010 at 6:47 PM, Tim Molendijk wrote: > >> Hey all, >> >> I've been developing jQuery plugins for quite some time now, and I >> like to think I got pretty good at it. One issue keeps nagging me >> though, and that is how to deal with private functions in a powerful >> yet elegant manner. >> >> My plugins generally look something like this: >> >> (function($) { >> >> $.fn.myplugin = function(...) { >>... >>// some shared functionality, for example: >>this.css('background-color', 'green'); >>... >> }; >> $.fn.mypluginAnotherPublicMethod = function(...) { >>... >>// some shared functionality, for example: >>this.css('background-color', 'red'); >>... >> }; >> >> }(jQuery); >> >> Now my question is: how to neatly DRY up that shared functionality? An >> obvious solution would be to put it in a function within the plugin's >> namespace: >> >> var fill = function($obj, color) { >> $obj.css('background-color', color); >> }; >> >> Although this solution is effective and nicely namespaced, I really >> dislike it. For one simple reason: I have to pass it the jQuery >> object. I.e. I have to call it like this: >> fill(this, 'red'); >> While I would like to call it like this: >> this.fill('red'); >> >> Of course we could achieve this result by simply putting 'fill' into >> jQuery.fn. But that feels very uncomfortable. Imagine having ten >> plugins developed based on this approach and each plugin putting five >> of those 'private' functions into the jQuery function namespace. It >> ends up in a big mess. We could mitigate by prefixing each of these >> functions with the name of the plugin they belong to, but that doesn't >> really make it more attractive. These functions are supposed to be >> private to the plugin, so we do not want to expose them to the outside >> world at all (at least not directly). >> >> So there's my question: does anyone of you have suggestions for how to >> get the best of both worlds. So being able to call 'private' plugin >> function in a way similar to this.fill('red') (or this.myplugin.fill >> ('red') or even this.myplugin().fill('red') etc.), while preventing >> jQuery function namespace pollution. And of course it should be light- >> weight, as these private functions might be called very frequently. >> >> Thanks for your ideas. >> >> Regards, >> Tim Molendijk >> > >
Re: [jQuery] Plugin design pattern (common practice?) for dealing with private functions
Maybe try using something like: $.myplugin.fill.call( this, "red" ); On Wed, Jan 13, 2010 at 6:47 PM, Tim Molendijk wrote: > Hey all, > > I've been developing jQuery plugins for quite some time now, and I > like to think I got pretty good at it. One issue keeps nagging me > though, and that is how to deal with private functions in a powerful > yet elegant manner. > > My plugins generally look something like this: > > (function($) { > > $.fn.myplugin = function(...) { >... >// some shared functionality, for example: >this.css('background-color', 'green'); >... > }; > $.fn.mypluginAnotherPublicMethod = function(...) { >... >// some shared functionality, for example: >this.css('background-color', 'red'); >... > }; > > }(jQuery); > > Now my question is: how to neatly DRY up that shared functionality? An > obvious solution would be to put it in a function within the plugin's > namespace: > > var fill = function($obj, color) { > $obj.css('background-color', color); > }; > > Although this solution is effective and nicely namespaced, I really > dislike it. For one simple reason: I have to pass it the jQuery > object. I.e. I have to call it like this: > fill(this, 'red'); > While I would like to call it like this: > this.fill('red'); > > Of course we could achieve this result by simply putting 'fill' into > jQuery.fn. But that feels very uncomfortable. Imagine having ten > plugins developed based on this approach and each plugin putting five > of those 'private' functions into the jQuery function namespace. It > ends up in a big mess. We could mitigate by prefixing each of these > functions with the name of the plugin they belong to, but that doesn't > really make it more attractive. These functions are supposed to be > private to the plugin, so we do not want to expose them to the outside > world at all (at least not directly). > > So there's my question: does anyone of you have suggestions for how to > get the best of both worlds. So being able to call 'private' plugin > function in a way similar to this.fill('red') (or this.myplugin.fill > ('red') or even this.myplugin().fill('red') etc.), while preventing > jQuery function namespace pollution. And of course it should be light- > weight, as these private functions might be called very frequently. > > Thanks for your ideas. > > Regards, > Tim Molendijk >
Re: [jQuery] Re: What is the proper way to write this if statement?
This is correct. I actually wrote a few jQuery extensions that handle this. The code is: $.fn.extend({ // checks to see if an element exists // if no callback is supplied, returns // a boolean value stating if the element // exists, otherwise executes the callback exists: function (callback) { if (typeof( callback ) === "function") { if (this.length > 0) { callback.call( this ); } return this; } else { return this.length > 0; } }, // checks to see if an element does not // exist. if no callback is supplied, returns // a boolean value stating if the element does // not exists, otherwise, executes the callback absent: function (callback) { if (typeof( callback ) === "function") { if (this.length === 0) { callback(); } return this; } else { return this.length === 0; } } }); Syntax would be var that = this; // scope $(this).parents("ul").absent( function () { $(that).addClass("active"); } ); or if you needed to do an if/else type scenario: var that = this; $(this).parents("ul").exists( function () { // this === $(this) this.removeClass("active"); } ).absent( function () { $(that).addClass("active"); } ); Or you could also use the function to return a boolean value: $(this).parent("ul").exists(); // true if ul is present $(this).parent("ul").absent(); // true if no ul is present Thanks, Matt On Wed, Jan 13, 2010 at 6:52 PM, pedalpete wrote: > Everything that I've seen says you have to check the length of the > element you are looking for. > > So I think you want > > if($(this).parents('ul').length==0){ > $(this).addClass("active"); > } > > > If a parent UL was found, the length would be > 0 >
Re: [jQuery] Re: Link Clicks Double Firing
What I'm assuming is happening here is that the even tied to the tag is firing as well as the click tied to the cell. It appears as though two windows are opened because the page you're currently on goes to the PDF and a new window is opened with the PDF. The easiest solution would be to add return false; to the bottom of the click function. You currently have the return false inside the each function. This isn't working due to scope. $('#factsheets td').click(function() { $(this).find('a').each(function(){ window.open(this.href); return false; }); return false; // stop the link from redirecting the page }); This would do it, and is unobtrusive as well. Though, since there is only one inside the cell, you might consider rewriting your code a little bit. Something more like: $("#factsheets").find("td").click( function () { window.open( $(this).find("a").attr("href") ); // open the PDF return false; // prevent the link from redirecting } ); Hopefully this makes sense to you. Thanks, Matt On Wed, Jan 13, 2010 at 5:38 PM, pedalpete wrote: > > Hi Bill, > > I'm still learning lots, and was hoping you could better explain what > was wrong with my solution (as it seems the other solutions are FAR > more complicated. > > What I was trying to acheive was to just disable the link for > javascript enabled browser, and keep it enabled for those without > javascript. > > As the link is inside the cell, and the javascript action is triggered > on any click within the cell, I believe my recommendation should work > well in all instances. > > I believe with .unbind('click'), the click on a link will not be > interpreted at all, and that the JS will always take the action. > > I may be misunderstanding what is happening under the covers, but what > I recommend does not unbind after a click, it would unbind the clicks > at load time if I've got it right. >
Re: [jQuery] Re: iTunes Style Slider
Z, thanks for the reply. I found that project yesterday after I had posted. I also found a couple of others. The problem is that they either a) only work in Firefox (like the one you found) or b) are not full-featured like the MooTools one. The closest I have found - which seems to be the only one that has good cross-browser support - is this one: http://paulbakaus.com/lab/js/coverflow/ Anyways, thanks again for your reply. It is much appreciated. :-)
[jQuery] iTunes Style Slider
Hello, I found an iTunes style slider/rotator that has been done in MooTools, demoed here: http://www.outcut.de/MooFlow/example-ajax.html. I was wondering if either a) such a thing already existed in a jQuery plugin, or b) if there was a jQuery master who could port it in quick fashion? If b), please contact me off-list and let me know how much you would charge and what the turnaround time would be. :-) Thanks in advance!
Re: [jQuery] jquery form...
Why? Simple. Because the variable does not exist. :D On Mon, Nov 9, 2009 at 7:09 PM, Lord Gustavo Miguel Angel wrote: > hi. > i´m try with this example: > http://www.malsup.com/jquery/form/#json > > but Alert(data.message) return "undefinited" > why? > > tk-. >
Re: [jQuery] jQuery only works in offline files?!
I'm going to say that there is about a 99.99% chance that the paths to your CSS and jQuery files are incorrect.
[jQuery] My jQuery Pumpkin... Jealous?
Just a little fun for Halloween 2009. I carved my pumpkin this year as the jQuery logo. I hope some in this group can appreciate it! :) http://mattkruse.com/2009/10/31/jquery-pumpkin/ Matt Kruse
Re: [jQuery] Superfish menus
On Wed, 2009-10-28 at 08:16 -0700, MICA wrote: > The website in question is - www.micalighting.com.au [...] > Can anyone help?? Not with the superfish, but you might want to reconsider that animated gif at the top. Cheers, -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot
[jQuery] Re: Structuring advice: cloning a set of dynamic dropdown menus
Figured this out myself using AJAX - I grab the dynamic second menu through ajax instead of toggling hidden options, which worked fine. On Oct 27, 4:45 pm, Matt wrote: > Oops, missed the link:http://imgur.com/p25xN.jpg > > On Oct 27, 4:45 pm, Matt wrote: > > > Hi there, > > > I have a table that looks like this: > > > The user can click the 'Add another category' link and another row is > > inserted. > > > My issue is here: those two select boxes are linked, meaning that > > depending on what is chosen from the first one, the options are > > changed in the second one. > > > When I clone this row, the new cloned row doesn't work properly - the > > first select box ('Publication') changes ALL of the 'Categories' > > choices in the second column. > > > My HTML is structured so that the table row contains each of the > > possible elements, each given an ID that corresponds to an ID > > number in the Publication . For example, the Publication > > dropdown HTML is: > > > > > Publication > option> > > Student > > Contract > > All Publications > option> > > > > > As a result, I have 4 hidden select boxes corresponding to each of > > these Publication choices. Make sense? > > > I feel like there must be a better way to organise this - can anyone > > advise me on how to do it? Above all, I can't seem to target the newly- > > cloned select boxes without grabbing them all. > > > Thanks, > > Matt
[jQuery] Re: Structuring advice: cloning a set of dynamic dropdown menus
Oops, missed the link: http://imgur.com/p25xN.jpg On Oct 27, 4:45 pm, Matt wrote: > Hi there, > > I have a table that looks like this: > > The user can click the 'Add another category' link and another row is > inserted. > > My issue is here: those two select boxes are linked, meaning that > depending on what is chosen from the first one, the options are > changed in the second one. > > When I clone this row, the new cloned row doesn't work properly - the > first select box ('Publication') changes ALL of the 'Categories' > choices in the second column. > > My HTML is structured so that the table row contains each of the > possible elements, each given an ID that corresponds to an ID > number in the Publication . For example, the Publication > dropdown HTML is: > > > Publication option> > Student > Contract > All Publications option> > > > As a result, I have 4 hidden select boxes corresponding to each of > these Publication choices. Make sense? > > I feel like there must be a better way to organise this - can anyone > advise me on how to do it? Above all, I can't seem to target the newly- > cloned select boxes without grabbing them all. > > Thanks, > Matt
[jQuery] Structuring advice: cloning a set of dynamic dropdown menus
Hi there, I have a table that looks like this: The user can click the 'Add another category' link and another row is inserted. My issue is here: those two select boxes are linked, meaning that depending on what is chosen from the first one, the options are changed in the second one. When I clone this row, the new cloned row doesn't work properly - the first select box ('Publication') changes ALL of the 'Categories' choices in the second column. My HTML is structured so that the table row contains each of the possible elements, each given an ID that corresponds to an ID number in the Publication . For example, the Publication dropdown HTML is: Publication Student Contract All Publications As a result, I have 4 hidden select boxes corresponding to each of these Publication choices. Make sense? I feel like there must be a better way to organise this - can anyone advise me on how to do it? Above all, I can't seem to target the newly- cloned select boxes without grabbing them all. Thanks, Matt
[jQuery] Re: Cloning a table row and changing its form field IDs
Never mind - Ricardo's genius post here solved it for me: http://groups.google.com/group/jquery-en/browse_thread/thread/f5469902b151daa2/b1908e69d723bfa6?lnk=gst&q=clone+IDs#b1908e69d723bfa6 On Oct 27, 10:43 am, Matt wrote: > Hi everyone. > > I'm writing a dynamic form that allows users to add fields. These > fields are contained in a table. > > I have this function to clone the rows (my table has an ID of > EventType) > > function addEventType() > { > var clonedRow = $("#EventType tr:last").clone(); > > $("input", clonedRow).attr('value', ''); // reset the form values > $("input:checked", clonedRow).attr('checked', ''); // uncheck any > checked boxes > > $("#EventTypeID").append(clonedRow); > $(".datepicker").datepicker(); // reset the datepicker widget > $(".datepicker").removeClass('hasDatepicker').datepicker(); > > } > > This gets more complicated because I'm using a Datepicker - this needs > each using the widget to have a unique ID. I've tried for a > few hours now to find some way to give the cloned row's s > unique IDs, but I'm getting nowhere. I tried setting a hidden form > field that counted the current ID, then incremented it for the new > rows, but I can't seem to get this to work. > > Can anyone point me in the right direction for incrementing the IDs of > the fields that are cloned? My HTML looks like this for each row: > > > > > > > > > > > Matt
[jQuery] Cloning a table row and changing its form field IDs
Hi everyone. I'm writing a dynamic form that allows users to add fields. These fields are contained in a table. I have this function to clone the rows (my table has an ID of EventType) function addEventType() { var clonedRow = $("#EventType tr:last").clone(); $("input", clonedRow).attr('value', ''); // reset the form values $("input:checked", clonedRow).attr('checked', ''); // uncheck any checked boxes $("#EventTypeID").append(clonedRow); $(".datepicker").datepicker(); // reset the datepicker widget $(".datepicker").removeClass('hasDatepicker').datepicker(); } This gets more complicated because I'm using a Datepicker - this needs each using the widget to have a unique ID. I've tried for a few hours now to find some way to give the cloned row's s unique IDs, but I'm getting nowhere. I tried setting a hidden form field that counted the current ID, then incremented it for the new rows, but I can't seem to get this to work. Can anyone point me in the right direction for incrementing the IDs of the fields that are cloned? My HTML looks like this for each row: Matt
[jQuery] superfish & wordpress. Where am I going wrong?
Hi, I'm trying to implement superfish onto a wordpress site I'm working on, but just can't get it to work. I believe I've done everything right, and searched the web for solutions but nothing as yet has helped. You can view the site at www.sdm-intl.com, it's the main blue menu on the site that is the one in question. I'm quite new to wordpress and don't have much experience with jQuery, so would appreciate any help! Many thanks
[jQuery] Sortable: get the element that received the sortable?
Hi everyone, I'm implementing a drag and drop newsletter, where my users can drag content to different areas of a template. Depending on where they drop the content, I need to add different HTML attributes to some of the code (essentially need to make the images float:left if they're dropped into a certain box). I've achieved a basic version of this using this code: $('.review_list').sortable({ receive: function(event, ui) { // somehow need to make this only apply to competition/ mainfeature $("img", ui.item).attr("align", "left"); $("img", ui.item).attr("vspace", "4"); $("img", ui.item).attr("hspace", "4"); }, connectWith: '#reviews' }); This adds align="left" vspace="4" hspace="4" onto any image dropped into an element with the 'review_list' class (I know I said it was float:left but this code will be emailed so I have to do it old school style...). Anyway: is there a way that I can get the element that has received the sortable item? It could be one of three in my case, and I only want this code to be added for two of them. I guess I could run a cleanup function when submitting that removed this addition for images in the other element, but this seems messier - I had assumed that the 'receive' event would return the receiving element.
[jQuery] Re: Adding selectors to $(this)?
Thanks James, the context parameter was what I needed. ui.item is an object returned by Sortable containing the elements used in sorting. On Oct 13, 10:40 pm, James wrote: > The jquery selector has a second parameter > 'context':http://docs.jquery.com/Core/jQuery#expressioncontext > > such that if defined it will only select what's a descendant of that > element. > You can also use find():http://docs.jquery.com/Traversing/find#expr > > By the way, what is ui.item? An object? (Class/ID) String? > > On Oct 13, 12:49 am, Matt wrote: > > > Hi all, > > > Writing a sortable list function. > > > My elements contain several items (headings, paragraphs etc) and > > I want to add a class to the headings when they've been sorted. > > > I have this code in my sortable init: > > > receive: function(event, ui) { > > $(ui.item).addClass('editable'); > > }, > > > This adds class="editable" to my newly-sorted element - cool. > > What I want, though, is to add this class to the within my . > > I tried: > > > receive: function(event, ui) { > > $(ui.item + ' h3').addClass('editable'); > > }, > > > but this just gave a syntax error. > > > Is there a way to do this? > > > Thanks, > > Matt
[jQuery] Re: jQuery speed seems slow
On Oct 14, 3:33 pm, JenniferWalters wrote: > Are jQuery searches slow versus using DOM? (i.e. > document.getElementById("whatever") ) Of course. jQuery adds many function calls and layers of abstraction when you do $('#whatever') vs. document.getElementById('whatever'). > It seems that it takes forever to do things that when done with > document.getElementById, goes much quicker. The speed of a simple $('#id') selector is slower than DOM, but it shouldn't take forever. In fact, it's very optimized for that case. If you provide a simplified example case that you think is overly slow, perhaps someone can identify other issues contributing to the performance problem. Matt Kruse
[jQuery] Adding selectors to $(this)?
Hi all, Writing a sortable list function. My elements contain several items (headings, paragraphs etc) and I want to add a class to the headings when they've been sorted. I have this code in my sortable init: receive: function(event, ui) { $(ui.item).addClass('editable'); }, This adds class="editable" to my newly-sorted element - cool. What I want, though, is to add this class to the within my . I tried: receive: function(event, ui) { $(ui.item + ' h3').addClass('editable'); }, but this just gave a syntax error. Is there a way to do this? Thanks, Matt
[jQuery] Re: My code is not working getting an error missing )
Add a ) to the end. You have to close the opening hover() function call.
[jQuery] Re: is(':checked') always returns false
On Oct 1, 1:16 pm, "bob.nel...@gmail.com" wrote: > I have a bunch of checkboxes that I want to have checked when the user > checks a master checkbox. You are writing too much unnecessary jQuery code! > HTML for master checkbox (within a container with id 'msgsInbox'): > type="checkbox" value="" onclick="checkAllMsgsIn()" tabindex="-1" /> Try: onclick="checkAllMsgsIn(this)" Then: > function checkAllMsgsIn() { > alert($('#msgCheckAllInbox').is(":checked")); //Used to debug this > $('#msgsInbox input.messageCheckbox').attr('checked', $ > ('#msgCheckAllInbox').is(':checked')); function checkAllMsgsIn(cb) { $('#msgsInbox input.messageCheckbox').attr('checked', cb.checked); } Much simpler. Matt Kruse
[jQuery] Re: keeping table header fix
On Thu, 2009-10-01 at 22:25 -0400, Karl Swedberg wrote: > have you tried overflow-y: auto; ? This works... (to some degree) table tbody { height: 799px; overflow-y: auto; overflow-x: hidden; } Cheers, -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot
[jQuery] IE7 does not play nice with $.load
It seems like IE7 will not actually make ajax requests unless I use $.ajax({cache:false}). I really like the $.load method though because of how it combines selecting the dom node to update, downloading the page, and then plugging it in. Is there some easy way of forcing IE to make ajax calls?
[jQuery] Re: fadeTo() possible speeds
>From the documentation: http://docs.jquery.com/Effects/fadeTo speed String, Number A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000). What else are you looking for? You use one of the three String speeds, or you put in a numeric value in milliseconds. On Sep 30, 1:54 pm, kali wrote: > here,http://docs.jquery.com/Effects/fadeTo > > why are all possible params not listed?? > > (for example for fadeIn(), fadeOut(), fadeTo() it just says "speed", > but why doesn't it list all possible speeds ("slow".. is there a > "fast"???) > > this site is a bit weird, if I go tohttp://docs.jquery.com/Main_Page > and search for fadeTo it says there is no such page, but if I search > for "jQuery fadeTo" in google then it directs me > tohttp://docs.jquery.com/Effects/fadeTo > > please, what are all possible values under "speed" for the fadeIn/Out/ > To methods??? > > thank you...
[jQuery] Re: jQuery .post function failing in Safari 4.03
I would first try putting your function call to reloadWindow() in the complete callback for the $.post function. So your post code would look like: $.post( "includes/update.php", { action: "y" }, reloadWindow); and take out the call to reloadWindow() after updateSession() You may have other backend issues, but i would try this first. On Sep 30, 10:00 am, jefrobaby wrote: > I need some cross browser support here before I leap off my balcony > this morning. > > I am working on a simple store which has links for the shopper to > enter a coupon code. These open a coupon code entry window. When the > user enter the code and clicks submit the following actions fire off; > check code for a match, if it's a match it posts a code to a php > script using the .post function which writes a record to the db, then > forces a page reload where the store checks the db for the coupon test > pass. > > My question is that it works perfectly in both IE 6, 7 , 8 and Firefox > 3.04 but the .post fails in Safari 4.03. > > I am using this version of jQuery (everything is working fine except > for the post back to the php script): > > http://ajax.googleapis.com/ajax/ > libs/jquery/1.3.2/jquery.min.js"> > > My js functions are as folows: > > function checkCode (){ > var couponParm = document.getElementById("coupon").value; > var input = sha1(couponParm); > var gradCode = "87dcce06a223ffd060aec5a027a00422ebfc6d8d"; > > if (input == gradCode){ > updateSession(); > reloadWindow(); > }} > > function updateSession (){ > $.post( "includes/update.php", { action: "y" });} > > function reloadWindow(){ > var url = window.location; > alert(url); > window.location.reload(); > > }
[jQuery] Re: keeping table header fix
On Sep 16, 7:55 pm, Macsig wrote: > Yes, I do but I don't see how that can help me out. > > Thanks > > On Sep 16, 4:01 am, Liam Byrne wrote: > > > do you actually have the headers in a , with the content in ? > > > Most people forget about those. > > > L > > > macsig wrote: > > > Hello guys, > > > I'd like to know if there is a way to keep a table header fixed on top > > > of a div while I scroll the table rows. > > > I have a div high 200px and the table itself is around 300px so when I > > > scroll down I'd like to always see the header on top. > > > I already use for the tabletablesorterso the solution must be > > > compatible with that plug-in. > > > > Thanks and have a nice day! > > > > Sig > > > > > > > No virus found in this incoming message. > > > Checked by AVG -www.avg.com > > > Version: 8.5.409 / Virus Database: 270.13.100/2375 - Release Date: > > > 09/16/09 05:51:00 Because then you can add this to your CSS: table.tablesorter tbody { height: 250px; overflow: auto; }
[jQuery] Re: been asked 1000 times?
Use class instead of id. $('.open-frame')
[jQuery] Re: Ajax problem on Safari/Chrome browsers
@ Mike - Thanks for making me take a closer look at the original code. I get it now. My bad. /me crawls back into his cave to hibernate some more
[jQuery] Re: Ajax problem on Safari/Chrome browsers
That code should not work on _any_ browser. In the onclick attribute you are grqbbing a reference to the containing div ($ ('#followButton2')), which clearly has no method named followUser. Try something like this instead:
[jQuery] Re: jQuery in loaded content doesn't work
My bad. I must admit that I did not read through the entire post, and also did not realize that the livequery plugin offered additional functionality. I was under the impression that it had been fully included into the core with live(). However, I have been corrected a couple of times after making this post. :-)
[jQuery] Re: jQuery in loaded content doesn't work
If you're using jQuery 1.3.x (and you should be), there's no need for the livequery plugin. http://docs.jquery.com/Events/live
[jQuery] Ajax
I made a page that would load 2 html pages, had a footer to show both, 2 links to show indivually, the divs to load them in, and the sticky footer css. My js seems valid, but the page is just completely blank. URL: http://testingspot.hostcell.net/sandbox/tests/jquery/ajax/ajax.html
[jQuery] $(this).css({"color" : "red"})
see that code in the subj.? i'm using FF 3.5, and no matter what i do, .css won't work!! any help?
[jQuery] Superfish
How do I go about changing the subnavigation background/position? I would like to add a vertical gradient to the subnavigation and am having a hard time. Any help would be appreciated. www.restorefoundation.schematixdesign.com
[jQuery] $.load doesn't trigger $(document).ready, but $.ajax({type:"GET", ...} does???
It seems like when I load a page into a div like this, the $ (document).ready code in the loaded page doesn't fire: $("#mydiv").load("/a"); But when I do this, the $(document).ready on /a does fire. Is this correct?
[jQuery] How to access variables in page loaded with $.load?
I have a page /a that has a line var aaa = 99; And I load that page /a into a div on another page. In the other page, I want access to that variable aaa. I tried this: $("#adiv").load("/a", function () { console.log(aaa); }) I get an error that aaa is undefined. What am I doing wrong?
[jQuery] Re: isFunction change in 1.3 and window.opener
On Sep 2, 2:21 pm, msoliver wrote: > Fair point. What you suggest certainly would be better than no check. > But, it's not a test that openerFunc is actually a function, just that > it exists and has an call property. That seems better to me than the crazy logic in 1.2's isFunction()! Any time that (typeof openerFunc != 'function') you are going to be making assumptions. Is there any chance in your code that openerFunc will be non-null (or undefined) and have a call property? If not, then how is this check not good enough? You could make it a little more robust by doing: if (openerFunc && typeof openerFunc.call=='function') Matt Kruse
[jQuery] Re: validation: how do I make sure a radio button is picked?
Perhaps I am misunderstanding something in your requirements, but with the validation plugin (link below), it is as simple as adding class="required" to the input tag. http://docs.jquery.com/Plugins/Validation HTH
[jQuery] validation: how do I make sure a radio button is picked?
I have a list of radio buttons, all with the same name, and each has a different value. I want a validator that tests if one is picked. How do I do this?
[jQuery] Re: isFunction change in 1.3 and window.opener
On Sep 2, 1:16 pm, msoliver wrote: > if ($.isFunction(openerFunc)) Why not just: if (openerFunc && openerFunc.call) ? Matt Kruse
[jQuery] Re: .not($.browser.msie && $.browser.version <= 7)
On Sep 2, 6:20 am, IschaGast wrote: > I am having rounded corners in a site but I don't want them in IE > because it does strange things with the corners. Many non-IE browsers already have native CSS support for rounded corners. If you want to exclude IE anyway, why not just use pure CSS? Matt Kruse
[jQuery] Re: Invalid Argument Line 12 1.3.2 IE 7 and 8rc1
I know this has been solved but thought I might add my own solution to a similar problem causing the same error message in IE, in case it's helpful to anyone. It was the DTD declaration - make sure it's first thing in the file and make sure it's correct! Some how, something had been inserted above the DTD and that broke IE and caused the error. Cheers. On Jul 28, 2:58 pm, kyleduncan wrote: > I have fixed this issue: > > Ie6, 7 and 8 were getting an invalid argument error because of CSS > padding: once padding was removed fro mthe textareas completely in a > separate IE stylesheet, IE6 and 7 and 8 all worked fine with multiple > textareas and no errors > > Opera was fixed by this problem also (it was showing the boxes very > high by default), although im not sure exactly what caused Opera to > correct - but it works fine now too! > > hope this helps others > > On Jul 22, 4:20 am, kyleduncan wrote: > > > > > It is caused byautogrow.js, but i have no idea how to fix it!autogrowisnt > > even working for me in IE6 and 7, when you click inside > > atextareait shrinks down to one line high and then doesnt expand as > > you type. and when you click in the secondtextareaon my page nothing > > happens at all (as ifautogrowdoesnt even activate). > > > On Jun 18, 1:13 pm, kitafe wrote: > > > > Does anyone have a solution. I have the same problem and I use jquery > > > 1.3.2 and ui 1.7. I've tried both the minified and the none minified > > > versions. > > > With ui accordion version 1.6rc2 i have no problem. But I then the > > > collapsible wont work. > > > > On Apr 26, 8:06 pm, sabrinax wrote: > > > > > I did, yes. You can see my sample page here:www.tattoozu.net/trial > > > > to see the problem > > > > > On Apr 26, 12:57 pm, dhtml wrote: > > > > > > On Mar 9, 3:43 am, phipps_73 wrote: > > > > > > > Hi, > > > > > > > I have just upgraded one of our development sites to 1.3.2 and ui > > > > > > 1.7. > > > > > > I have also updated all of the plugins > > > > > > (forms,validate,thickbox,calculation,blockUI,autogrow) to the latest > > > > > > versions which should all be compatible with 1.3.2 and the site is > > > > > > working perfectly in Firefox 3 on OS X and XP. > > > > > > > However on IE8rc1 and inIE7compat mode I am getting an Invalid > > > > > > Argument error reported at line 12 of jquery-1.3.2.min.js. That is > > > > > > the > > > > > > usual really helpfulIEerror message and I have been unable to track > > > > > > down the source of the problem. > > > > > > Do you get the same error with the normal, non-minified version? > > > > > > Garrett
[jQuery] Approaching popup callback hell
I'm using a modal dialogs and I love them, but I haven't found a really elegant way to handle actions in the dialog window that require changes to the parent page. Here's an example. I have a monthly calendar page that lists employee names on the days they are supposed to work. Clicking on an employee name opens a "shift detail" page in a modal dialog. That shift detail page has more information like the specific tasks planned for the day, the start time and stop time of the shift, etc. >From this shift detail screen, I can remove this particular employee from the schedule by submitting an AJAX POST from this popup. After I remove the employee, I need to update both the popup window and the original page that hosted the link to the popup window. Right now I do this by adding a callback that fires when the AJAX POST succeeds. That callback then updates both pages. The callback is named "after_remove_employee". This system gets really nasty when I use the "shift detail" popup on different screens. For example, in addition to the monthly view, I also have a weekly view with more information. So after an employee is removed from the schedule on the weekly view, I need to do some different things in the callback. Right now, the way I handle this is that I define the same callback twice. I define "var after_remove_employee = function (data) {...} on the weekly view to do what it needs there, and then I define it differently on the monthly view. I've simplified the problem to help explain it. In reality, I have lots of different popups on lots of different pages, and in each popup, there are many different possible actions. I'm sure I'm not the only one that's been in this scenario. What is an elegant solution? I'm thinking about using custom events. So, the callback after a successful AJAX POST would just fire an "employee removed" event, and everybody subscribed would get a reference to the event object and do whatever they want. However, I've never used JS events before, and I don't know if this is even possible. Please, any feedback is welcome.
[jQuery] How do I compare two form fields using the form validation plugin?
I have a form with two radio button lists. Each list has the same set of choices. I want to make sure that something is checked in both lists and that the value in the first list is not the value in the second list. I know I could write my own submit handler to do this, but I'd like to work within the jquery form validation plugin because I already use it in other places. Any ideas how to do this?
[jQuery] Possible IE8 Bug with jQuery
I believe I have found a bug in IE8; it's possible that it's something jQuery is doing, but I really doubt it. I'm only cross-posting this here in the hopes that someone can suggest a workaround, because I have tried everything I can think of. A code sample is available here: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/f265c5b1-a45d-4949-85b2-86a97a884dc1 The issue I'm seeing is that changing the contents of a table cell in IE8 randomly causes the width of the td element to change. In the code sample above, I'm using toggle and replacing the content with an input element, but I have tried using just a click handler and inserting something as simple as another string of text. In every combination of styles and script I have tried, I'm still able to get IE8 to randomly change the width of td elements when their contents change. I have tried using jQuery to force the td width back to the correct value, but that doesn't seem to do anything. (Of course, the code behaves fine in both Firefox and Chrome.) So, anyone have any suggestions on what to try? Any help at all would be greatly appreciated since I'm basically out of ideas.
[jQuery] Re: Bug? -- toggle() of TR broke in IE8
On Aug 4, 10:18 am, Liam Potter wrote: > It's down to the way IE handles tables, nothing to do with a jquery bug > (people are so quick to shout out that word). > Boiled down, you can't do a lot of things to tr's in IE, and display > none is one of the things you can't change. Then why does the example work in IE8 using jQuery 1.2.1? You can certainly set a tr to display:none in IE. Matt Kruse
[jQuery] google.load speed with jquery
I'm using google jsapi to load jquery. The example shows to do this: http://www.google.com/jsapi";> google.load("jquery", "1.3.2"); google.setOnLoadCallback(function() { // Place init code here instead of $(document).ready() }); The problem I'm having is this... I'm also including google map api, google search api and jquery ui. all using .load. I then have several jquery plugins I'm using along with alot of code in the document.ready. My thinking was that I include two js files the first being http://www.google.com/jsapi and the 2nd having this: google.load("jquery", "1.3.2"); google.load("jqueryui", "1.7.2"); google.setOnLoadCallback(function() { }); so my code would like like this in the index file: http://www.google.com/jsapi";> http://myserver.com/js/combined- load-js-files-and-doc-read.js"> I'm wondering if this is hurting performance on the site by putting .load in another script file. My reasoning was that to include 30k+ of js plugins and code in index.php file would be bloat, so I figured I would put it in a separate file. Does anyone have any tips on how to do this properly, even if lets say I just include the google.load in the header and have the document.ready how do I pull in this massive js file? Secondly... and I think this steams from the performance problem but i'm using jquery ui tabs... and they take forever to render, mostly because I think all of this js is loading. TIA!
[jQuery] Re: How Would You Use Superfish Drop Down Menus with CSS Sprites2?
Thanks for the tip. Like every time you're trying something new, it's two steps forward and three steps back. I'll try you suggestion.
[jQuery] How Would You Use Superfish Drop Down Menus with CSS Sprites2?
I have a menu that I've already set up with ALA's CSS Sprites2 (http:// www.alistapart.com/articles/sprites2/) now I have to add a drop down menu into the mix. What would be the best way to achieve this, or rather what would I need to change in the Superfish scripts to get this to work? This is what I have for the HTML so far... Home About Contact Us Menu Appetizers Private Dining Private Dine Options Option 1 Event Menu Events Events Merchandise Merchandise __ And this is the CSS: .nav { width: 960px; height: 149px; background: url(../images/primenav_rollovers.jpg) no-repeat green; } .nav li { display: inline; } .nav li a:link, .nav li a:visited { position: absolute; top: 0; height: 149px; text-indent: -9000px; z-index: 10; } /*HOME*/ .nav .home a:link, .nav .home a:visited { left: 0; width: 270px; } .nav .home a:hover, .nav .home a:focus { background: url(../images/primenav_rollovers.jpg) no-repeat 0px -149px; } .nav .home a:active { background: url(../images/primenav_rollovers.jpg) no-repeat 0px -298px; } .current-home .home a:link, .current-home .home a:visited { background: url(../images/primenav_rollovers.jpg) no-repeat 0px 0px; cursor: default; } .nav-home, .nav-home-click { position: absolute; top: 0; left: 0px; width: 270px; height: 149px; background: url(../images/primenav_rollovers.jpg) no-repeat 0px 149px; } .nav-home-click { background: url(../images/primenav_rollovers.jpg) no-repeat 0px -298px; } /*ABOUT*/ .nav .about a:link, .nav .about a:visited { left: 270px; width: 114px; } .nav .about a:hover, .nav .about a:focus { background: url(../images/primenav_rollovers.jpg) no-repeat -270px -149px; } .nav .about a:active { background: url(../images/primenav_rollovers.jpg) no-repeat -270px -298px; } .current-about .about a:link, .current-about .about a:visited { background: url(../images/primenav_rollovers.jpg) no-repeat -270px -298px; cursor: default; } .nav-about, .nav-about-click { position: absolute; top: 0; left: 270px; width: 114px; height: 149px; background: url(../images/primenav_rollovers.jpg) no-repeat -100px -149px; } .nav-about-click { background: url(../images/primenav_rollovers.jpg) no-repeat -100px -298px; } /*MENU*/ .nav .menu a:link, .nav .services a:visited { left: 384px; width: 108px; } .nav .menu a:hover, .nav .menu a:focus { background: url(../images/primenav_rollovers.jpg) no-repeat -384px -149px; } .nav .menu a:active { background: url(../images/primenav_rollovers.jpg) no-repeat -384px -298px; } .current-menu .menu a:link, .current-menu .menu a:visited { background: url(../images/primenav_rollovers.jpg) no-repeat -384px -298px; cursor: default; } .nav-menu, .nav-menu-click { position: absolute; top: 0; left: 384px; width: 108px; height: 149px; background: url(../images/primenav_rollovers.jpg) no-repeat -384px -149px; } .nav-menu-click { background: url(../images/primen
[jQuery] Re: PNGFixes are breaking SuperFish in IE6...SUPRISE!
This problem now seems to be even more widespread. I installed just a basic, pure, CSS dropdown menu and even it does not work with Supersleight, UnitPNGfix or even jQuery's pngfix. GRR On Jul 24, 3:44 pm, Matt wrote: > I've tried a few different PNGFixes thinking that maybe the problem > was unique to one particular fix, but unfortunately all PNGFixes are > breaking my menu. Basically, without the PNGFix, the menu works fine. > But, as soon as the PNGFix loads, I lose my hover ability and > naturally the dropdown feature. This is all CSS (plus jQuery) at the > moment. It works in all other browsers. > > Has anyone ever run across this problem? > > Thanks! > Matt
[jQuery] PNGFixes are breaking SuperFish in IE6...SUPRISE!
I've tried a few different PNGFixes thinking that maybe the problem was unique to one particular fix, but unfortunately all PNGFixes are breaking my menu. Basically, without the PNGFix, the menu works fine. But, as soon as the PNGFix loads, I lose my hover ability and naturally the dropdown feature. This is all CSS (plus jQuery) at the moment. It works in all other browsers. Has anyone ever run across this problem? Thanks! Matt
[jQuery] Re: jQuery => License
On Tue, 2009-07-21 at 00:46 -0700, Kaps wrote: > Hello Team, > > I just want to know that do I need to purchase a license if I want to > use jquery on public sites. > > Waiting for your quick reply!! jQuery is Free Software. Feel free to use as you'd like. You don't need to purchase anything because it is also free software. -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Superfish hover problem
Hovering on the navigation that has no children - what's new, or Learn with us. Instead of showing a blank subnavigation, it is still showing the current drop down. Is there any way to make it blank? Example of my issue: http://update.creativejunction.org.uk/talk-with-us/ This superfish navigation is being used with the silverstripe CMS.
[jQuery] Superfish nav-bar style hover problem
Hovering on the navigation that has no children - what's new, or Learn with us. Instead of showing a blank subnav, it is still showing the current drop-down. Is there any way to make the children blank? Example of my issue: http://update.creativejunction.org.uk/talk-with-us/ This superfish navigation is being used with the silverstripe CMS.
[jQuery] Re: Input that allows only numbers.
On Fri, 2009-07-17 at 08:45 -0700, Caio Landau wrote: > So let me get it, key's code numbered between (and including) 48 and > 57 are numbers? I used an "alert" dialog to determine the keycodes, you could probably also use an ascii chart. You also may want to include the codes for: backspace arrow keys delete etc. Cheers, > > On Jul 17, 11:18 am, Matt Zagrabelny wrote: > > On Thu, 2009-07-16 at 16:12 -0700, Caio Landau wrote: > > > Well, that a simple question, I hope. I have an input ( > > type="text" />) on my page, and I want it to only accept numbers, so > > > if the user types anything that's not a number, it will be removed > > > instantly. > > > > > A simplified example just to illustrate: > > > > > > > > > > > > > > > This works for me... > > > > > > > > > src="/usr/share/javascript/jquery/jquery.js"> > > > > $(function() { > > $('#numbersonly').keypress( > > function(event) { > > return ((event.which >= 48) && (event.which <= 57)); > > } > > );}); > > > > > > > > > > > > > > > > > > Cheers, > > > > -- > > Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 > > University of Minnesota Duluth > > Information Technology Systems & Services > > PGP key 1024D/84E22DA2 2005-11-07 > > Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 > > > > He is not a fool who gives up what he cannot keep to gain what he cannot > > lose. > > -Jim Elliot > > > > signature.asc > > < 1KViewDownload -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: Input that allows only numbers.
On Thu, 2009-07-16 at 16:12 -0700, Caio Landau wrote: > Well, that a simple question, I hope. I have an input ( type="text" />) on my page, and I want it to only accept numbers, so > if the user types anything that's not a number, it will be removed > instantly. > > A simplified example just to illustrate: > > > > This works for me... $(function() { $('#numbersonly').keypress( function(event) { return ((event.which >= 48) && (event.which <= 57)); } ); }); Cheers, -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: Treeview plugin for navigation - solution
Sorry for the repeat posts, but the link above was incorrect (I'm at a different computer right now). This is the revision I used: http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js?rev=4685 ...although there appear to be more recent revisions...I'm not sure which is best. On Jul 16, 12:06 pm, "Matt B." wrote: > Edit: I realized that "cookieOptions" is actually a version 1.4.1 > feature, only available from the SVN. The feature has not yet been > added to the minified version, so you need to grab the uncompressed > version here: > > http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js > > So it's not undocumented, it's just that 1.4.1 hasn't officially been > released yet. > > On Jul 16, 8:45 am, "Matt B." wrote: > > > I just thought I'd post a solution I came up with that may be helpful > > to anyone using thetreeviewplugin fornavigation. > > > The problem I ran into was that the cookie persistence was working, > > but since I was using the tree fornavigationto different directories > > of my site, sometimes the cookie wouldn't get set correctly and the > > state of the tree would end up being one step behind what the user had > > just clicked -- so the previously clicked node would be expanded > > rather than the current one. > > > Thanks to some helpful posts I found on here, I discovered that the > > problem was the cookie path. > > > The solution is to use an (undocumented) option that was added to the > > plugin as of version 1.4: 'cookieOptions', which lets you set the > > cookie path. > > > If yournavigationtree could potentially be used for any page in your > > domain, then you would set the cookie path to the root, like this: > > > cookieOptions: {path: '/'} > > > ..or if your site is in a subdirectory you should use this: > > cookieOptions: {path: '/my_subdirectory/'} > > > In my case I'm using PHP and I have my site root stored in a constant > > called WEB_ROOT, so my full code was: > > > $(document).ready(function() { > > $("#sideNav ul").treeview({ > > collapsed: true, > > unique: true, > > persist: "cookie", > > cookieOptions: {path: ''} > > }); > > }); > > > Hope this is helpful to somebody.
[jQuery] Re: Treeview plugin for navigation - solution
Edit: I realized that "cookieOptions" is actually a version 1.4.1 feature, only available from the SVN. The feature has not yet been added to the minified version, so you need to grab the uncompressed version here: http://dev.jquery.com/browser/trunk/plugins/treeview/jquery.treeview.js So it's not undocumented, it's just that 1.4.1 hasn't officially been released yet. On Jul 16, 8:45 am, "Matt B." wrote: > I just thought I'd post a solution I came up with that may be helpful > to anyone using thetreeviewplugin fornavigation. > > The problem I ran into was that the cookie persistence was working, > but since I was using the tree fornavigationto different directories > of my site, sometimes the cookie wouldn't get set correctly and the > state of the tree would end up being one step behind what the user had > just clicked -- so the previously clicked node would be expanded > rather than the current one. > > Thanks to some helpful posts I found on here, I discovered that the > problem was the cookie path. > > The solution is to use an (undocumented) option that was added to the > plugin as of version 1.4: 'cookieOptions', which lets you set the > cookie path. > > If yournavigationtree could potentially be used for any page in your > domain, then you would set the cookie path to the root, like this: > > cookieOptions: {path: '/'} > > ..or if your site is in a subdirectory you should use this: > cookieOptions: {path: '/my_subdirectory/'} > > In my case I'm using PHP and I have my site root stored in a constant > called WEB_ROOT, so my full code was: > > $(document).ready(function() { > $("#sideNav ul").treeview({ > collapsed: true, > unique: true, > persist: "cookie", > cookieOptions: {path: ''} > }); > }); > > Hope this is helpful to somebody.
[jQuery] Treeview plugin for navigation - solution
I just thought I'd post a solution I came up with that may be helpful to anyone using the treeview plugin for navigation. The problem I ran into was that the cookie persistence was working, but since I was using the tree for navigation to different directories of my site, sometimes the cookie wouldn't get set correctly and the state of the tree would end up being one step behind what the user had just clicked -- so the previously clicked node would be expanded rather than the current one. Thanks to some helpful posts I found on here, I discovered that the problem was the cookie path. The solution is to use an (undocumented) option that was added to the plugin as of version 1.4: 'cookieOptions', which lets you set the cookie path. If your navigation tree could potentially be used for any page in your domain, then you would set the cookie path to the root, like this: cookieOptions: {path: '/'} ..or if your site is in a subdirectory you should use this: cookieOptions: {path: '/my_subdirectory/'} In my case I'm using PHP and I have my site root stored in a constant called WEB_ROOT, so my full code was: $(document).ready(function() { $("#sideNav ul").treeview({ collapsed: true, unique: true, persist: "cookie", cookieOptions: {path: ''} }); }); Hope this is helpful to somebody.
[jQuery] Firefox 3.5 and same-site requests?
In firefox 3.5, http://www.chrisevert.org/ throws an error that I haven't seen previously: [Exception... "Component returned failure code: 0x805e000a [nsIXMLHttpRequest.open]" nsresult: "0x805e000a ()" location: "JS frame :: http://www.chrisevert.org/a/scripts/jquery-1.3.2.js?recache=1247683374 :: anonymous :: line 3517" data: no] Line 3517 of jquery-1.3.2: http://skitch.com/expertseries/ba4fu/jquery-1.3.2 The request itself is local, via $().load('/url/local/file.php'); Maybe something to do with this? https://developer.mozilla.org/En/HTTP_access_control#Preflighted_requests Anyone having similar experiences?
[jQuery] Re: A job for you?
On Wed, 2009-07-15 at 05:58 -0700, Geuintoo wrote: > I didn't got any answer. > Mabe I was not clear: > > I look for a jQuery - Programmer, > who I pay to devlope some code. Here are some thoughts... Include a link to a web page that talks about the project. What jQuery things need to be written, the overall project, timeline, etc. Include in the page the compensation, a bit about yourself or your company, etc. Cheers, PS. This is a list where information is freely exchanged and people contribute out of their own free time. Perhaps no one is interested in taking on more work (even though it is paid) ? -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] validation plugin's date method doesn't like mm-dd-yyyy formatted dates
I'm using this validation plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/ and it is great. However, it rejects dates like 07-14-2009 as invalid. Is there some way to add a list of valid formats? If not, should I write my own method to match that particlar format?
[jQuery] Re: jQuery syntax question
On Mon, 2009-07-13 at 12:09 -0700, Matthew wrote: > So it seems like everyday I learn a new way to code the same thing. > What I am trying to do is add some code after a paragraph depending on > how many paragraphs are in the content. I'm not to worried about logic > right now just syntax. Here is my code: > > > My questions is regarding this syntax: $("p", "body#seniors #text") > [2].append(something); > > Shouldn't that append something after the 3rd paragraph in the #text > div (if it exists)? I believe the selector would grab all the paragraphs (that is your "p"), then add into the array the element of id "text" that lies within the body element with id of "seniors". The third element in that array is not necessarily a paragraph element. Perhaps you could scab together a little DOM for us to look at: etc. etc. Cheers, -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: both 'if' and 'else' blocks being executed
On Fri, 2009-07-10 at 23:51 +0200, Massimo Lombardo wrote: > Please, using plain English only, explain what you want to do. > Then we'll try to help ;) Alright. > The glitch is probably caused by the fact that the two input fields > *do* share the same name; then when you touch one, you *do* alter > both! Bug or feature? Having two DOM elements with the same name attribute is still valid (see .) My main question is how does both the 'if' block and the 'else' block get executed in the same pass through the function? > As far as I got it, (and pretending that I got it right) you're trying > to enable/disable an hidden input field based on another checkbox's > checked state. That is it. That way only one of the two inputs of name="billable" get sent to the handler on the server. This page is a RT (request tracker) module and RT handles the processing of the (server-side.) I would rather not modify the RT codebase to handle the checkbox - I thought it could be done via JS. My main questions still stands, how does both the 'if' and 'else' blocks get executed on the same pass through the function? Thanks for the time and help. Cheers, > On Fri, Jul 10, 2009 at 22:38, Matt Zagrabelny wrote: > > Greetings, > > > > I am experiencing some crazy stuff, at least crazy to me... > > > > Both the 'if' and 'else' blocks (according to firebug) are being > > executed in the following anonymous function: > > > > > > > > > src="/usr/share/javascript/jquery/jquery.js"> > > > > $(function() { > > add_billable_oncheck(); > > }); > > > > function add_billable_oncheck() { > > var billable_hidden = $('#billable_hidden')[0]; > > var billable_checkbox = $('#billable_checkbox')[0]; > > if ((billable_hidden != null) && > > (billable_checkbox != null)) { > >$(billable_checkbox).change( > > function(event) { > > > > // These are the blocks that both get executed on checkbox check > >if (billable_checkbox.checked) { > > billable_hidden.disabled = true; > >} else { > > billable_hidden.disabled = false; > >} > > // ^^^ > > > > } > >); > > } > > } > > > > > > > > > > > value="No" /> > > > value="Yes" /> > > > > > > > > > > Does anyone have any insight into this one? > > > > If I add 'return;' statements at the end of the blocks, things work as > > expected, however I wouldn't expect that I should have to do that. > > > > Thanks for the help, > > > > -- > > Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 > > University of Minnesota Duluth > > Information Technology Systems & Services > > PGP key 1024D/84E22DA2 2005-11-07 > > Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 > > > > He is not a fool who gives up what he cannot keep to gain what he cannot > > lose. > > -Jim Elliot > > > > > -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: both 'if' and 'else' blocks being executed
On Fri, 2009-07-10 at 14:40 -0700, Matthew wrote: > Can you explain to me why you are disabling a hidden input field? I > assume the idea is that they are both checkboxes with the the same > name attribute. Maybe I could help if I understood why you are doing > this. The form handler on the server side processes both if the checkbox is checked. I only want one to be processed. Regardless, both blocks are being executed... (crazy) Thanks, > On Jul 10, 1:38 pm, Matt Zagrabelny wrote: > > Greetings, > > > > I am experiencing some crazy stuff, at least crazy to me... > > > > Both the 'if' and 'else' blocks (according to firebug) are being > > executed in the following anonymous function: > > > > > > > > > src="/usr/share/javascript/jquery/jquery.js"> > > > > $(function() { > > add_billable_oncheck(); > > > > }); > > > > function add_billable_oncheck() { > > var billable_hidden = $('#billable_hidden')[0]; > > var billable_checkbox = $('#billable_checkbox')[0]; > > if ((billable_hidden != null) && > > (billable_checkbox != null)) { > > $(billable_checkbox).change( > > function(event) { > > > > // These are the blocks that both get executed on checkbox check > > if (billable_checkbox.checked) { > > billable_hidden.disabled = true; > > } else { > > billable_hidden.disabled = false; > > } > > // ^^^ > > > > } > > ); > > }} > > > > > > > > > > > >> value="No" /> > >> value="Yes" /> > > > > > > > > > > Does anyone have any insight into this one? > > > > If I add 'return;' statements at the end of the blocks, things work as > > expected, however I wouldn't expect that I should have to do that. > > > > Thanks for the help, > > > > -- > > Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 > > University of Minnesota Duluth > > Information Technology Systems & Services > > PGP key 1024D/84E22DA2 2005-11-07 > > Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 > > > > He is not a fool who gives up what he cannot keep to gain what he cannot > > lose. > > -Jim Elliot > > > > signature.asc > > < 1KViewDownload -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] both 'if' and 'else' blocks being executed
Greetings, I am experiencing some crazy stuff, at least crazy to me... Both the 'if' and 'else' blocks (according to firebug) are being executed in the following anonymous function: $(function() { add_billable_oncheck(); }); function add_billable_oncheck() { var billable_hidden = $('#billable_hidden')[0]; var billable_checkbox = $('#billable_checkbox')[0]; if ((billable_hidden != null) && (billable_checkbox != null)) { $(billable_checkbox).change( function(event) { // These are the blocks that both get executed on checkbox check if (billable_checkbox.checked) { billable_hidden.disabled = true; } else { billable_hidden.disabled = false; } // ^^^ } ); } } Does anyone have any insight into this one? If I add 'return;' statements at the end of the blocks, things work as expected, however I wouldn't expect that I should have to do that. Thanks for the help, -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: noob problem with selector and wrapped set - SOLVED
Thanks for the info, Ralph and Keegan. I performed the ugly: jQuery('#' + id.replace(/:/g, '\\:')) But the other suggestions look good too (plus there is nothing to escape - bonus.) Cheers, On Thu, 2009-07-09 at 16:15 -0700, KeeganWatkins wrote: > > Or you can use the attribute selector for brevity: > > jQuery("[id='" + actual element id + "']") > > which will return the same element. Hope that helps. > > > On Jul 9, 6:10 pm, KeeganWatkins wrote: > > Ralph is correct, as jQuery uses the colon as a prefix for selector > > filters like :hidden and :last. To fix, you can just pass in the raw > > node like this: > > > > jQuery(document.getElementById( actual element ID)) > > > > which will return the wrapped set. Cheers. > > > > On Jul 8, 3:47 pm, Ralph Whitbeck wrote: > > > > > > > > > It's not a problem with Prototype and it being mixed cause you get the > > > same > > > problem if you just isolate it to just a page with jQuery. > > > > > The problem seems to be an invalid ID name. I was able to get a match > > > when > > > I took :: out of the ID name. > > > > > Ralph > > > > > On Wed, Jul 8, 2009 at 12:14 PM, Matt Zagrabelny > > > wrote: > > > > > > Greetings, > > > > > > I am attempting to use jQuery in a Prototype environment (Request > > > > Tracker RT3.8). > > > > My ready handler is working, but my first attempt at establishing a > > > > wrapped set is not working. > > > > > > Some snippets: > > > > > > jQuery.noConflict(); > > > > > > jQuery(document).ready(function() { > > > > set_max_length('Object-RT::Ticket--CustomField-29-Value', 4); > > > > } > > > > > > function set_max_length(id, max_length) { > > > > alert("There are " + jQuery('#' + id).size() + " elements in the > > > > wrapped set."); > > > > } > > > > > > My alert message comes back with 0 (zero) elements in the wrapped set. > > > > There is an input element with id = 'Object-RT::Ticket--CustomField-29- > > > > Value' in the DOM. Am I missing anything? > > > > > > Thanks for the help, > > > > > > -Matt Zagrabelny -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] Re: jQuery on IE
So now enter this in IE's address bar: http://servidor/astral/web/js/jquery.js Does it load? If yes, then create this document: http://servidor/astral/web/js/</a> jquery.js" type="application/x-javascript" > alert($); What does it alert? Make sure IE's settings are such that errors will be shown. Matt Kruse On Jul 9, 3:27 pm, Paulodemoc wrote: > The generated code is > http://servidor/astral/web/js/</a> > jquery.js" type="application/x-javascript" > > I tryied to add the > alert('jQuery not loaded'); > but no alert was shown > But still, the error persists... > I will paste here the full code, so you guys can see: > > http://www.w3.org/ > TR/xhtml11/DTD/xhtml11.dtd"> > http://www.w3.org/1999/xhtml";> > > > Astral > > type="text/css" /> > > > > function showSubProdutos() { > $("#submenu").fadeIn("slow"); > }; > function hideSubProdutos() { > $("#submenu").fadeOut("fast"); > }; > function showProjetos() { > $("#submenu2").fadeIn("slow"); > }; > function hideProjetos() { > $("#submenu2").fadeOut("fast"); > }; > function hideAll() { > $("#submenu").fadeOut("fast"); > $("#submenu2").fadeOut("fast"); > }; > function changeSubject() { > if($("#assunto").find('option').filter(':selected').text() == > "Receita") { > //$("#msg-cont").toggle(2000, function(){ > $("#recipe-cont").toggle > (2000); }); > $("#msg-cont").slideUp("slow", function(){ > $(this).hide(); > $("#recipe-cont").slideDown(2000); > }); > } > else { > $("#recipe-cont").slideUp("slow", function(){ > $("#msg-cont").slideDown("slow"); > }); > } > }; > > $(document).ready(function(){ > var nome = ""; > var pos = ""; > var html = > document.createElement("div"); > $(html).attr("id", > "submenu"); > > $(html).css("z-index", 30); > > $(html).css("position", "relative"); > > $(html).css("background-color", "#D7"); > $(html).css("float", > "left"); > $(html).css("width", > "140px"); > $(html).css("top", > "125px"); > $(html).css("left", > "320px"); > $(html).hide(); > > $(window.document.body).prepend(html); > > $(html).append("<center><a href='<?php echo base_url > ().'index.php/home/produtos';?>' style='font-family:Tahoma, Arial, > Helvetica, sans-serif;color:#972021;font-size:11px;line-height: > 25px;font-weight:bold;'>Linha Doméstica</a><br /><a href='<?php > echo base_url().'index.php/home/produtos_institucionais';?>' > style='font-family:Tahoma, Arial, Helvetica, sans- > serif;color:#972021;font-size:11px;line-height:25px;font- > weight:bold;'>Linha Institucional</a></center>"); > html = > document.createElement("div"); > $(html).attr("id", > "submenu2"); > > $(html).css("z-index", 30); > > $(html).css("position", "relative"); >
[jQuery] Re: jQuery on IE
On Jul 9, 3:14 pm, Paulodemoc wrote: > Hello all... i have correctly included all scripts, and I am using > jQuery 1.3.2 > i have included the script like that: > View the source of the generated page, find the url in the tag, and enter it in manually to see if jQuery loads. Your script url may be relative, and IE may be interpretting it differently for some reason. In any case, jQuery is not being loaded. Try this: <script language="javascript" src="<?php echo base_url();?>js/ jquery.js" type="application/x-javascript" >alert('jQuery not loaded'); Matt Kruse
[jQuery] Re: jQuery on IE
On Jul 9, 2:55 pm, expresso wrote: > Also, do you really have
[jQuery] Re: Access by item in the array
expresso, Please stop going on and on and on (ad infinitum). (I am trying to be polite) Thank you. On Thu, 2009-07-09 at 12:33 -0700, expresso wrote: > Funny thing is, I'll be blogging about this carousel. And you may > find my implementation to be pretty complex but you would not know > about the entire implementation and you assume that what we are doing > is "simple" > > On Jul 9, 2:03 pm, expresso wrote: > > >>>making it difficult to understand what you are asking > > > > tell me how it's difficult, I am very thorough in explaining the > > situation and things tried. > > > > On Jul 9, 1:57 pm, expresso wrote: > > > > > You've got it backwards it makes more sense and keeps the clutter > > > out if you stay in the same topic. > > > > > I did not say not to stay on the same topic. I said if I start > > > veering off into anther discussion that's talking about a different > > > approach (in this case in that previous thread I started with a > > > question about obtaining the LAST ). Then I wondering maybe > > > instead I can just iterate through the list of and grab some by > > > index. At that point, that's a whole different issue or scope. Yea, > > > that time I should have stuck with the thread because I already > > > committed to the question on the index. > > > > > Anyway I get it. But I should not be posting 2 different questions on > > > the same thread which is what I try to avoid > > > > > On Jul 9, 1:54 pm, expresso wrote: > > > > > > how the hell am I being rude? > > > > > > And second, I am giving information to help you help me. Again I try > > > > all sorts of shit before I post stuff. I don't just post on every > > > > step of the way. I am showing you what I have tried. So you either > > > > get called out for not giving enough information or giving too > > > > little. > > > > > > Chill > > > > > > On Jul 9, 11:04 am, MorningZ wrote: > > > > > > > "so it's only respectful on my part to > > > > > start a new thread on a different topic that's veering off in the same > > > > > thread. Not cool. " > > > > > > > You've got it backwards it makes more sense and keeps the clutter > > > > > out if you stay in the same topic. > > > > > > > As Liam points out you already asked the index question, AND it > > > > > was answered by Charlie, in the topic you created just 13 hours ago > > > > > > >http://groups.google.com/group/jquery-en/browse_thread/thread/8832916... > > > > > > > and yet, here's an identical topic asking the identical question with > > > > > 2 min apart two sentence ramblings on them all > > > > > > > Realize what this list for what it is: a mailing list where lots of > > > > > us provide free help out of our own time > > > > > > > making it difficult to understand what you are asking, being rude to > > > > > people trying to show you the way, rambling on and on with the same > > > > > stuff all that doesn't lend itself very well to make your issues > > > > > worth other peoples time and effort > > > > > > > . > > > > > > > On Jul 9, 11:12 am, expresso wrote: > > > > > > > > Because sometimes I get into other topics not related to my original > > > > > > posts in those other thread so it's only respectful on my part to > > > > > > start a new thread on a different topic that's veering off in the > > > > > > same > > > > > > thread. Not cool. > > > > > > > > On Jul 9, 9:30 am, Liam Potter wrote: > > > > > > > > > how about reading all the replies to your other thread about this? > > > > > > > > > $("#mycarousel > li:eq(10)").css("margin-right", "5px"); > > > > > > > > > expresso wrote: > > > > > > > > Is it possible to target certain in an unordered list by > > > > > > > > index > > > > > > > > with jQuery? I thought maybe I could use .index but was not > > > > > > > > able to > > > > > > > > get the syntax right. > > > > > > > > > > I thought maybe something like this would work but is has not: > > > > > > > > > > $("#mycarousel > li").index(i).css("margin-right", "5px"); -- Matt Zagrabelny - mzagr...@d.umn.edu - (218) 726 8844 University of Minnesota Duluth Information Technology Systems & Services PGP key 1024D/84E22DA2 2005-11-07 Fingerprint: 78F9 18B3 EF58 56F5 FC85 C5CA 53E7 887F 84E2 2DA2 He is not a fool who gives up what he cannot keep to gain what he cannot lose. -Jim Elliot signature.asc Description: This is a digitally signed message part
[jQuery] noob problem with selector and wrapped set
Greetings, I am attempting to use jQuery in a Prototype environment (Request Tracker RT3.8). My ready handler is working, but my first attempt at establishing a wrapped set is not working. Some snippets: jQuery.noConflict(); jQuery(document).ready(function() { set_max_length('Object-RT::Ticket--CustomField-29-Value', 4); } function set_max_length(id, max_length) { alert("There are " + jQuery('#' + id).size() + " elements in the wrapped set."); } My alert message comes back with 0 (zero) elements in the wrapped set. There is an input element with id = 'Object-RT::Ticket--CustomField-29- Value' in the DOM. Am I missing anything? Thanks for the help, -Matt Zagrabelny
[jQuery] Re: jQuery and javascript objects
On Jul 8, 1:54 am, Nic Hubbard wrote: > I have some JSON that I returned from my server. I then converted it > to an object using eval. It is only then that I can start > manipulating it with jQuery (trust me). Currently the multilevel > object is set in a var. Is there a way that I can then have jQuery > use this, to get values from it? Or is there no sense in trying to > use jQuery for this, and it might not even be of help? Why would you want to use jQuery to handle a standard javascript object? What exactly do you want to do with it? Matt Kruse
[jQuery] checkboxTree Plugin
Hello Everybody, I have rewritten and posted my jquery checkboxTree plugin that I originally put out a year ago. Tried to add features and options people were asking for. Information can be found here: http://floatmargin.com/2009/jquery-checkbox-tree-plugin-new-and-improved/ The github repository can be found here: http://github.com/magearwhig/jquery-checkboxtree -Matt W.
[jQuery] Re: check/uncheck all checkboxes with specific id
On Jun 30, 12:24 pm, "evanbu...@gmail.com" wrote: > $(':checkbox.chkEvent').each(function() { > var el = $(this); > el.attr('checked', el.is(':checked') ? '' : > 'checked'); > }) Avoid attr(), and try to avoid fitting every problem into a jQuery solution... Try this simple code: $(':checkbox.chkEvent').each(function() { this.checked = !this.checked; } I also keep my "run" plugin handy for simple things like this: // A General "run" function to simplify coding $.fn.run = function(fn) { if (typeof fn=='string') { fn = new Function(fn); } this.each(fn); } Then: $(':checkbox.chkEvent').run("this.checked = !this.checked"); Whether that's actually more efficient to write depends on the situation ;) Matt Kruse
[jQuery] Re: jquery .noconflict
That is exactly what it means.
[jQuery] Re: jquery .noconflict
Straight from the docs http://docs.jquery.com/Core/jQuery.noConflict *NOTE:* This function must be called after including the jQuery javascript file, but *before* including any other conflicting library, and also before actually that other conflicting library gets used, in case jQuery is included last.
[jQuery] Re: (validate) Radio button values
Thanks guys. I really appreciate all the help. I'm still stuck, though. I can't get anything to work now, although I can't seem to figure out why. I'm definitely not a programmer, so please be gentle, though feel free to explain things to me like I'm a 5 year-old. I won't be offended. :-) Here's where I'm at after trying to integrate your posts. Again, this code doesn't produce any results, so I'm really stuck. jQuery.validator.addMethod("correctAnswer", function(value, element, params) { var radioValue = $("#main").find("input[type='radio']").val(); // returns the selected value from the radio button group return this.optional(element) || value > params; }, "Select the correct answer to move on."); $.validator.setDefaults({ submitHandler: function() { alert("Go to next question."); } }); $.metadata.setType("attr", "validate"); $(document).ready(function() { $("quiz_form").validate({ rules: { correctAnswer: 1 } }); }); Answer 1 Answer 2 Answer 3 Answer 4 Please select an answer. All I want to be able to do is present the user with four answers and force the user to pick the correct answer before being allowed to move to the next question. It doesn't matter if the answer is in the code as the target for this is NOT the type who would open up the source and go through it. :-) -Matt On Jun 29, 9:06 am, Alexandre Magno wrote: > Matt, > > You litteraly used the custom validation rule that I gave just for > example, it was to follow that line, but that method it's to verify if > that field it's greater than a number, used for minAge. > > so when I put: > > rules: { > minAge: 18 > > } > > If you analyze, they return if the value it's greater that you passed > at "return this.optional(element) || value > params;" > > I made this for you understand how works and not to make the whole > code, before this parte you have to implement like Mac made, but still > not right, I thing the follow code should work but I didint tested: > > * Mac, you start to implement but you use a given id in a given radio, > the custom method receive the value of the field, you don't need to > tie in a given id, it can be general like below > > jQuery.validator.addMethod("correctAnswer", function(value, element, > params) { > > return this.optional(element) || value == params; > > }, "Select the correct answer to move on."); > > So you can make: > > $("quiz_form").validate({ > rules: { > correctAnswer: 1 > > } > }); > > And the method will check if the value selected in radio is the same > that the parameter you pass, this case 1 > > I hope this should help and work for you > > They return if the field it's greater in the syntax > > On 29 jun, 00:03, Mac wrote: > > > > > Heya Matt > > > Looks like you have created the custom method for the validation, but > > you are not calling it anywhere. You are still setting the validation > > method to be the default "required". > > You need to add the method as a class to the element (as you did > > originally) or specify it as a rule in the $.ready() call to validate > > (). > > > I'm also not entirely sure that your custom method will produce the > > results you expect (haven't tested it). > > If you struggle with that - try the following: > > > jQuery.validator.addMethod("correctAnswer", function(value, element, > > params) { > > > var radioValue = $("#main").find("input[type='radio']").val(); // > > returns the selected value from the radio button group > > return this.optional(element) || value > params; > > > }, "Select the correct answer to move on."); > > > In order to provide a value for params you need to call the method in > > the following manner: > > >> value="1" name="answers" /> (if you want the radio with a valu
[jQuery] Re: (validate) Radio button values
Alexandre, this sounds like it would do pretty much what I need. I followed your post but I can't seem to get it working. Can you look at the code below and tell me where I've gone wrong? Sorry to ask for all the help but I think I'm kind of close and I just want to get it done! :-) jQuery.validator.addMethod("correctAnswer", function(value, element, params) { return this.optional(element) || value > params; }, "Select the correct answer to move on."); $.validator.setDefaults({ submitHandler: function() { alert("Go to next question."); } }); $.metadata.setType("attr", "validate"); $(document).ready(function() { $("quiz_form").validate({ rules: { answer1: "required" } }); }); Answer 1 Answer 2 Answer 3 Answer 4 Please select an answer. On Jun 26, 1:11 pm, Alexandre Magno wrote: > Hello, > > If you need a simple solution to this you should consider create a new > validation rule for the validate plugin, it's easy... > > this it's a example how to create a rule to verify its the age its > greater than 18: > > jQuery.validator.addMethod("minAge", function(value, element, params) > { > return this.optional(element) || value > params; > > }, "You should be greater than 18 to enter in this website"); > > So you should create a rule that you pass for example the right > answear in rule an then will be checked all throught the validate > > This rule you created with the syntax above could be added in > additional.methods.js that cames with the validate plugin > > it was clear? > > Alexandre Magno > Interface Developerhttp://blog.alexandremagno.net > > On Jun 25, 7:12 pm, Matt Riley wrote: > > > > > Yeah, like I thought, I'm back again. ;-) > > > Below is the code I've been cobbling together from your previous post. > > Please feel free to slap me around and tell me where I've done bad. > > Right now, the form validation works fine (if there is nothing > > selected then the jquery validation comes up). However, when I hit the > > submit button, nothing happens. I'm sure I've screwed something up > > royally but I'm not an experienced enough programmer to figure it all > > out before the sun dies. > > > > > $.validator.setDefaults({ > > submitHandler: function() { > > var correctAnswer = 1 > > $('.theAnswer').each( > > function(){ > > var temp_val = $('.theAnswer').val(); > > var temp_id = $('.theAnswer').attrib('id'); > > if(temp_val=='selected'){ > > if(temp_id == correctanswer){ > > alert("Correct!"); > > } > > else{ > > alert("Try Again."); > > } > > } > > > }); > > } > > }); > > > $.metadata.setType("attr", "validate"); > > $(document).ready(function() { > > $("#quiz_form").validate(); > > > }); > > > > > > > > > > > > > > > > > > > > > id="answer1" value="1" validate="required:true" /> > > Answer 1 > > > > > > > class="theAnswer" id="answer2" > > value="2" /> > > Answer 2 > > > > > > > class="theAnswer" id="answer3" > > value="3" /> > > Answer 3 > > > > > > > class="theAnswer" id="answer4" > > value="4" /> > > Answer 4 > > > > Please sel
[jQuery] Re: call a method outside a jquery object
On Jun 26, 12:44 pm, jakiri hutimora wrote: > Actually I really need to access to a method inside another function. > $( > function(){ > function openMenu(){ > doSomething(x); > } > function closeMenu(){ > doSomething(x); > } > > } > ); Why are you defining these functions inside $()? Just define them outside of $() and they will be global. function openMenu(){ doSomething(x); } function closeMenu(){ doSomething(x); } $(openMenu); If you want a function to be available outside of the function scope that is currently executing, then define it outside. Matt Kruse
[jQuery] Re: (validate) Radio button values
Yeah, like I thought, I'm back again. ;-) Below is the code I've been cobbling together from your previous post. Please feel free to slap me around and tell me where I've done bad. Right now, the form validation works fine (if there is nothing selected then the jquery validation comes up). However, when I hit the submit button, nothing happens. I'm sure I've screwed something up royally but I'm not an experienced enough programmer to figure it all out before the sun dies. $.validator.setDefaults({ submitHandler: function() { var correctAnswer = 1 $('.theAnswer').each( function(){ var temp_val = $('.theAnswer').val(); var temp_id = $('.theAnswer').attrib('id'); if(temp_val=='selected'){ if(temp_id == correctanswer){ alert("Correct!"); } else{ alert("Try Again."); } } }); } }); $.metadata.setType("attr", "validate"); $(document).ready(function() { $("#quiz_form").validate(); }); Answer 1 Answer 2 Answer 3 Answer 4 Please select an answer. On Jun 25, 4:27 pm, Matt Riley wrote: > Thanks for your reply. I'm going to give it a go with what you > suggested, although I'm not exactly a seasoned pro at this so I will > probably get stuck and come back begging for more help. :-) > > I should have mentioned that this thing needs to run locally from a > user's hard disk without a requirement for server-side processing. If > this was not the case, I would've probably pursued a php solution as > I'm slightly more comfortable with that (jquery is very new to me). It > doesn't much matter if the correct answer is hidden in the source of > the page somewhere; these quizzes will just be used for basic users > who wouldn't know/care to look in the source anyway. > > Again, thank you for your reply. I'll probably be back. LOL. > > -Matt > > On Jun 25, 3:16 pm, Lee R Lemon III wrote: > > > > > well like many things this has a variable answer... > > > but what I think you will need to do is write a script that gets the > > correct answer (I would use ajax calls to server so the answer can not > > be seen in the browser code) > > then set an event on the submit button that cycles through your radio > > buttons for the correct answer easiest way to do that is add a class > > to each and do something sorta like.. > > //outside a function (before your document.ready as well) > > var correctanswer; > > //somewhere set the value of correctanwser > > $('.your_class').each( > > function(){ > > var temp_val = $('.your_class').val(); > > var temp_id = $('.your_class').attrib('id'); > > if(temp_val=='selected'){ > > if(temp_id == correctanswer){ > > //code for correct answer here > > } > > else{ > > //code for wrong answer here > > } > > } > > > ) > > > On Jun 25, 2:35 pm, Matt Riley wrote: > > > > I'm making a simple quiz using jquery and the validate plug-in. I > > > think I'm really close but just need a nudge over the last hump. :-) > > > > I have a radio button group that requires the user to select at least > > > one button. That part is working. However, what I want to do is also > > > check to see if the user selected a certain button (i.e. the correct > > > answer). Only if the correct answer is satisfied will the form then > > > validate and move on to the next quiz question. > > > > Here's my code so far. Any help is greatly appreciated. > > > > > > > $.validator.setDefaults({ > > > submitHandler: function() { > > > alert("Submitted!"); > > > > } > > > }); > > > > $.metadata.setType("attr", "validate"); > > > > $(document).ready(function() { > > > $("#quiz_form").validate();}); > > > > > > > > > > > > > > > > >
[jQuery] Re: (validate) Radio button values
Thanks for your reply. I'm going to give it a go with what you suggested, although I'm not exactly a seasoned pro at this so I will probably get stuck and come back begging for more help. :-) I should have mentioned that this thing needs to run locally from a user's hard disk without a requirement for server-side processing. If this was not the case, I would've probably pursued a php solution as I'm slightly more comfortable with that (jquery is very new to me). It doesn't much matter if the correct answer is hidden in the source of the page somewhere; these quizzes will just be used for basic users who wouldn't know/care to look in the source anyway. Again, thank you for your reply. I'll probably be back. LOL. -Matt On Jun 25, 3:16 pm, Lee R Lemon III wrote: > well like many things this has a variable answer... > > but what I think you will need to do is write a script that gets the > correct answer (I would use ajax calls to server so the answer can not > be seen in the browser code) > then set an event on the submit button that cycles through your radio > buttons for the correct answer easiest way to do that is add a class > to each and do something sorta like.. > //outside a function (before your document.ready as well) > var correctanswer; > //somewhere set the value of correctanwser > $('.your_class').each( > function(){ > var temp_val = $('.your_class').val(); > var temp_id = $('.your_class').attrib('id'); > if(temp_val=='selected'){ > if(temp_id == correctanswer){ > //code for correct answer here > } > else{ > //code for wrong answer here > } > } > > ) > > On Jun 25, 2:35 pm, Matt Riley wrote: > > > > > I'm making a simple quiz using jquery and the validate plug-in. I > > think I'm really close but just need a nudge over the last hump. :-) > > > I have a radio button group that requires the user to select at least > > one button. That part is working. However, what I want to do is also > > check to see if the user selected a certain button (i.e. the correct > > answer). Only if the correct answer is satisfied will the form then > > validate and move on to the next quiz question. > > > Here's my code so far. Any help is greatly appreciated. > > > > > $.validator.setDefaults({ > > submitHandler: function() { > > alert("Submitted!"); > > > } > > }); > > > $.metadata.setType("attr", "validate"); > > > $(document).ready(function() { > > $("#quiz_form").validate();}); > > > > > > > > > > > > > > > > > > > > > > > name="answers" > > validate="required:true" /> > > Answer 1 > > > > > > > name="answers" /> > > Answer 2 > > > > > > > name="answers" /> > > Answer 3 > > > > > > > name="answers" /> > > Answer 4 > > > > Please select an > > answer. > > > > > > > > > > > > > > >
[jQuery] (validate) Radio button values
I'm making a simple quiz using jquery and the validate plug-in. I think I'm really close but just need a nudge over the last hump. :-) I have a radio button group that requires the user to select at least one button. That part is working. However, what I want to do is also check to see if the user selected a certain button (i.e. the correct answer). Only if the correct answer is satisfied will the form then validate and move on to the next quiz question. Here's my code so far. Any help is greatly appreciated. $.validator.setDefaults({ submitHandler: function() { alert("Submitted!"); } }); $.metadata.setType("attr", "validate"); $(document).ready(function() { $("#quiz_form").validate(); }); Answer 1 Answer 2 Answer 3 Answer 4 Please select an answer.
[jQuery] Jquery JQzoom is not a function error, why?
I am working on an ecommerce site that uses smarty tpl files and I am having trouble implementing JQzoom, I have already use a java based menu system so I am aware of the {literal}{/literal} I am trying to use JQzoom for product images and when the product page loads the java isn't working. Firefox error console says. "Error: $(".jqzoom").jqzoom is not a function Source File:/index.php?target=products&product_id=30472 Line: 23" When I run firefox's javascript debugger, jquery.jqzoom1.0.1.js is there and the.jqzoom function is present NB, this isn't working in explorer either Here is my code {include file="meta.tpl"} {if $content == "product_details" || $content == "products"} {literal} $(document).ready(function(){ $(".jqzoom").jqzoom(); This is line 23 }); {/literal} {/if} It has been suggested to me that the library isn't being loaded, but I don't understand why. I tried using Jquery.noConflict () but that didn't make a difference. Anyone got any ideas or suggestions?
[jQuery] Re: how to call a JS function by pass into a JS
On Jun 20, 3:24 am, Davis wrote: > i want pass a JS function name into a function and call it. Why do you want to pass a name? Just pass the function reference instead. > babababa http://www.javascripttoolbox.com/bestpractices/#onclick You could do: bababa function ajax_loadpage(func) { func(); } Matt Kruse
[jQuery] Re: Form Traversal Best Practices
On Jun 19, 1:21 pm, Karl Swedberg wrote: > Here, .attr() is a bit of a misnomer, because it's really looking at > DOM properties, not (x)HTML attributes. I'm pretty sure either one > works, but I use .attr('checked', true) Indeed, the code internally sets the DOM attribute rather than calling setAttribute(). It's been this way for a long time, and it's a favorite criticism of jQuery from some on comp.lang.javascript. Will it ever be fixed? > Actually, when I can get away with avoiding .attr() I usually do. For > example, I would do: > this.checked = true; jQuery should really have .prop() which would work like attr() usually intends to, but deal only with DOM properties rather than trying to manipulate actual attributes. Script authors usually want to deal with properties anyway, and attr() only makes it confusing. Matt Kruse
[jQuery] Re: jQuery text toggle effect
On Jun 19, 9:02 am, mojoeJohn wrote: > obviously, i want the text to toggle the words "show" and "hide" in > accordance to the slide toggle. I keep this in my toolbox: // Toggle text within an element using regular expressions. // Useful for changing "show" to "hide" and back when toggling element displays, for example jQuery.fn.toggleText = function(a,b) { return this.html(this.html().replace(new RegExp("("+a+"|"+b +")"),function(x){return(x==a)?b:a;})); } Example: $('#mydiv').toggleText('show','hide'); You can pass in regex text, and it can toggle text within a string like: "Click here to show all items" and it will just toggle the word "show" to "hide". Hope it's useful. Matt Kruse
[jQuery] [Validate] trigger validation by input:button
Hi, I have been working on a big form and using jquery plug-in (wizard form) to divide tit into small subforms. Now, I am trying to integrate the Validation plugin to deal with the validation and come up with an issue. I run validation on subforms which contains two buttons(back, next). Those 2 buttons are input:button type but not input:submit. I realise the Validation plug-in would trigger the validation on submit event. Is there any way I can modify the code so that it could handle my requirement? Having a look on the multipart demo which is the exact scenario I am dealing with. However, the page below is not working. I tried on both IE and FF. http://jquery.bassistance.de/validate/demo/multipart/ Please advise. Cheers, Matt
[jQuery] Re: variable manipulation
On Jun 9, 9:35 am, simon wrote: > $.myvariable1 > $.myvariable3 > $.myvariable2 > now I would like to add the number part of the variable to it > dynamically. var i=1; $['myvariable'+i] === $.myvariable1 See: http://www.javascripttoolbox.com/bestpractices/#squarebracket Matt Kruse
[jQuery] Re: jQuery's code first lin e (function(){・・・・・
On Jun 9, 7:39 am, darwin liem wrote: > function funcname1(){ /* do something here */ } > now we do something else like setTimeout to trigger the funcname1 > setTimeout("funcname1",1000); <-- this will delay until 1 second to trigger > the function No it won't. This will do nothing, since you would need "funcname1()" to actually run the function. Or preferrably: setTimeout(funcname1,1000); Matt Kruse
[jQuery] Re: Selectors only matching first element
Thanks. Unfortunately this doesn't seem to work either. The div example from the page should work as it was copied directly, but it doesn't. This is bizarre. If it helps, I have the tablesorter, validate and maybe even UI plugins set up here as well.. could one of them be interfering? On Jun 4, 6:26 pm, "Mauricio \(Maujor\) Samy Silva" wrote: > There isn't in HTML Specs a true value for checked attribute. > Try: > $("input:checkbox").attr("checked", "checked"); > Maurício > -Mensagem Original- > De: matt > Para: jQuery (English) > Enviada em: quinta-feira, 4 de junho de 2009 18:12 > Assunto: [jQuery] Selectors only matching first element > ... > $("input:checkbox").attr("checked", true); > > checks the first box only.