[jQuery] Re: changing the selected option in a select
rolfsf wrote: : this didn't work (as well as several other variations): : $('a.cancel').click( function(){ : $('select option[value=0]').attr(selected,selected); : }); : : can someone clue me in? $('a.cancel').click( function(){ $('select').val('--'); }); HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Thickbox Alternative that Works with jQuery
Andy Matthews wrote: : If you like Thickbox, why are you looking for something different? The grass is always greener on the other side of the browser. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Computing value for css key
praxis wrote: : $(div#lt).css(left, eval(parseInt($ : (div#content).css(left))-24)); : : The problem is, I can't get it to happen. (div#content).css(left) may be returning auto instead of a dimension. Can you provide an example page that illustrates the problem? HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Problems appending inputs with quotes in the value
benjam wrote: : i.e.- If I try something like the following: : : $('form').append('input type=text name=foo value=Quote - \This : is a quote\ /'); : : The element that gets appended to the form has the following html: You could use a single quote as a delimeter. $('form').append('input type=text name=foo value=\'Quote - \This is a quote\\' /'); But that looks mighty ugly. You could change the quoted quotes to an html entity. $('form').append('input type=text name=foo value=Quote - #34;This is a quote#34; /'); HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Accessing un-parented text inside a known object
sparkpool wrote: : This finds span.bar, as I expected, but not what I want: : jQuery('#zzz :first') $('#foo').contents().get(0) .contents() is used to get childNodes. http://docs.jquery.com/Traversing/contents HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/ Don't tread on my bandwidth. Trim your posts.
[jQuery] Re: getting the ID number of a cloned table row
Bruce MacKay wrote: : Hello folks, : : I'm trying to duplicate a row of an existing table using a function : adapted from : http://www.nabble.com/Add-Table-row-to12989886s27240.html#a13300133 : : My problem is that I cannot identify the identifier of the last row : (of the original table). From the html you provided, this gets the last ID. // The match should return an array with the current id in the 0 // position. The + sign in front converts this ID to a number. var currentID = + $(clonedRow).find('input').attr('id').match( /\d+/ )[0]; var newID = currentID + 1; The problem is that clone() does not work right in Internet Exploder. There's a patch due, but no advance yet. So, the solution works on FF, but not on IE. (http://www.fusioncube.net/?p=196) In fact, the method above needs filter() to work on IE. // Solution for IE. var currentID = + $(clonedRow).filter('input').attr('id').match( /\d+/ )[0]; var newID = currentID + 1; : function duplicateRow(){ [snip] Manipulating the html directly probably isn't the most jQuery-ish way to handle this. $(clonedRow).find( '#bc' + currentID ).eq(0).attr({ id: 'bc' + newID, name: 'correctans' + newID }); $(clonedRow).find( '#theans' + currentID ).eq(0).attr({ id: 'theans' + newID, name: 'answer' + newID }); $(clonedRow).find( '#fb' + currentID ).eq(0).attr({ id: 'fb' + newID, name: 'feedback' + newID }); // Add to the new row to the original table $( #myTable).append( clonedRow ); So, for now, you may need another solution besides clone(). HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: New to jquery. Things just don't work.
Sathya wrote: : ${'a'}.click(function() { That should be: $('a').click(function() { HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Is it possible to auto increment an appended value?
Gorkfu wrote: : How would I create a cap to put on the counter, so it doesn't go : higher than 250? Thanks Can you update us n the code you are using now and how (or why) you would want to add a cap? Two possibilities come to mind. Create an object that checks itself as it changes or just check the value after each increment. I tend to lean toward objects, but they tend to take more time to write. Knowing the context of the limitation (or cap) would help a lot. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: can't access any plugins from within function
ajpiano wrote: : i'm in the midst of developing an application with many jquery : plugins, and i've just run into a bizarre problem. my app uses a lot : of ajax to populate different divs that i'm sorting using sortable. : anyhow, the issue is as follows. Can you provide an actual example of the problem? Perhaps a link to your app? HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Not a plugin but code for anyone trying to have collapse-able menu with cookies
Karl Swedberg wrote: : On my test page (http://test.learningjquery.com/cookie-menu.html), I : put a link to another page with the same script and menu so you can : see the persistence of the expand/collapse state. Never being able to leave well enough alone and having a little time on my hands, I squeezed the cookie information into a separate object. By calling an instance of it (using new) we can easily have multiple menus on a page. Here is the beginning of the cookieMenu code: $.fn.cookieMenu = function(cookieName){ var $topLevel = this.find('li ul'); $topLevel.hide(); var menuCookie = new $.cookie.menu(cookieName); menuCookie.showCookie(); Using a cookie object reduced the size of each click function. The bigIndex() function is a private method of the $.cookie.menu object. var $this = $(this), $checkElement = $this.next('ul'); if ( menuCookie.isOpen(index) ) { $checkElement.show(); } $this.click(function() { if ($checkElement.is(':hidden')) { $checkElement.slideDown(); menuCookie.open(index); } else { $checkElement.slideUp(); menuCookie.close(index); } menuCookie.showCookie(); return false; }); I also made calling the menus little simpler. It assumes the structure of the menu is a simple unordered list of lists like we have been using. script type=text/javascript src=/site/code/jquery.cookie.js/script script type=text/javascript src=/site/code/jquery.cookie-menu.js/script script type=text/javascript $(document).ready(function() { $('#menu-1').cookieMenu('cookie-1'); $('#menu-2').cookieMenu('cookie-2'); }); /script There are three menus on my test page. The top menu is the same on both pages while the bottom one on each page use different cookies. http://www.clarksonenergyhomes.com/demos/jq/cookie-menu.html HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: attr ie bug
hcvitto wrote: : hi i'm using this code to add the target=_blank attribute to links. : : $(a[href]).each(function(){ : if ($(this).hasClass(ppt) || $(this).hasClass(pdf) || $ : (this).hasClass(allegato) || $(this).hasClass(doc) || $ : (this).hasClass(jpg) || $(this).hasClass(xls) || $ : (this).hasClass(external) || $(this).hasClass(zip)){ : $(this).attr(target,_blank); : } : }); : : it works fine in firefox but not with ie which throws a javascript : error i can't identify. It works on IE6 on windows XP. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Fighting a closure
timothytoe wrote: : This next one is obviously a work of JavaScript art (as opposed to the : former, which is a more jQuery solution). Actually, it's very jQuery-ish. We can use a similar form to add custom methods to the jQuery object. : Does anyone want to explain it? : : for ( i=0;i5;i++ ) { : (function(num) { : $(#port+num).click(function() { bigchart(num) }); : })(i); : } In javascript, you can force a block of code to run by wrapping it in two sets of parentheses ( ... code ... )(). For example, this function will not run until it is called and being anonymous (it has not been assigned to a variable) there is no way to call it: function(num) { $(#port+num).click(function() { bigchart(num) }); }; But, if I wrap it in parenthesis like this, it will run as it is encountered. (function(num) { $(#port+num).click(function() { bigchart(num) }); })(); The problem is that num remains undefined. To define it we can pass a value in the second parenthesis. This set of five routines will run for each value 0 through 4. (function(num) { $(#port+num).click(function() { bigchart(num) }); })(0); (function(num) { $(#port+num).click(function() { bigchart(num) }); })(1); (function(num) { $(#port+num).click(function() { bigchart(num) }); })(2); (function(num) { $(#port+num).click(function() { bigchart(num) }); })(3); (function(num) { $(#port+num).click(function() { bigchart(num) }); })(4); That's an awful lot to type. To bad we aren't programmers, then we could write a loop to step through the values passed to ... Hey, we are programmers! Carpenters of the future and all that. for ( i = 0; i 5 ;i++ ) { (function(num) { $(#port+num).click(function() { bigchart(num) }); })(i); } HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Interface Plugin for Jquery
[EMAIL PROTECTED] wrote: : I start getting errors in my firefoy error console. : Can someone please tell how can i solve this problem . What errors are you getting? HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: IE7 it does't work (bug?)
mixfox wrote: : here is my code : : $(document).ready(function() { $('#imageid').load(function(){ : : alert('hello'); : : }); }); : : #imageid is an img lable's ID That works for me. Perhaps the error is in the html portion of your page. Are you sure the image has an id of id=imageid? id=#imageid will fail. If you cannot fix the problem show us your whole page. !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.dfwrein.com/html4-embed.dtd; html head titleFoo/title meta http-equiv=Content-Type content=text-html; charset=utf-8 script type=text/javascript src=/site/code/jquery-1.2.2.pack.js/script script type=text/javascript $(document).ready(function() { $('#imageid').load(function(){ alert('hello'); }); }); /script /head body img id=imageid width=125 height=157 src=/site/images/people/mike_butler.jpg /body /html HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: jquery VS internet explorer
ZiTAL wrote: : Hi, i have done a very simple example of jquery slide, but it doesn't : work correctly in internet explorer, it blinks in the beginning and at : the end. Thanks for all (sorry for my bad english). : : link: : http://zital.no-ip.org/jquery/ [gets on soap box] Always, always, always start with well formed html(xhtml). Validate it to be certain that is not the problem. The DOM depends on you knowing how to write well formed markup. If you don't write it, the browser makes stuff up to fill in any missing pieces. When the browser guesses wrong, your code and markup often fail. Browsers guess wrong a lot. Get out of Quirks mode and specifically define the character encoding. This will solve a lot of cross browser problems. Use a DOCTYPE at the top of all your xhtml (and html) pages (see this url for xhtml: http://www.w3schools.com/tags/tag_doctype.asp). Here is the xhtml Transitional DOCTYPE declaration. It will get you out of Quirks mode. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; Use a character encoding in the header. There are a lot of different encodings out there. I find utf-8 to my liking. Do a search for other character encodings. meta http-equiv=Content-Type content=text-html; charset=utf-8 This will solve many of the problems you have with IE 6. Including the one you presented here. If you have a cross browser problem, go validate your page, first. Validate the css and html(xhtml). Fix the validation problems and see if the other problem is still happening. You may be surprised by the result. I think I have learned more about css and html from validating (and repairing) my pages than from any other single source. I have gotten so anal about it that I created a custom DTD for one client. [gets off soap box] I tested your script with this header and IE6 performed fine. I am using the jquery version 1.2.2. I didn't test your page using your source. . !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html head titleFoo/title meta http-equiv=Content-Type content=text-html; charset=utf-8 script type=text/javascript src=/site/code/jquery-1.2.2.pack.js/script script type=text/javascript var http='http://zital.no-ip.org/jquery/'; $(document).ready(function (){ $(#close).click(function(){ $(#top).slideUp(slow, function(){ $(#container).slideUp(slow); }); }); [snip] HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Superfish problem with IE7
eugene33 wrote: : I have a little problem with superfish and IE7 (probably IE6 too : couldn't test it) It fails under IE6 as well. The problem seems to be the relative positioning of the #content. The default is static positioning works fine. The relative position is causing the problem. As is: div#content { position: relative; display: block; float: left; width: 480px; min-height: 642px; padding: 10px; background: #F1EDE1; border-left: 1px solid #ED; } Repaired: div#content { position: static; display: block; float: left; width: 480px; min-height: 642px; padding: 10px; background: #F1EDE1; border-left: 1px solid #ED; } According to the docs, the superfish author watches this list. He may have some insight on exactly how to keep the relative positioning and the menu. I suspect the menu normally displays fine, but under the #content due to its positioning. BTW, I solved this problem by backing out all the stylesheets except the superfish one. I tested the page and the menu worked in IE. Then I added stylesheets back in until I isolated the layout stylesheet. Did more testing. Next I guessed about blocking out whole sections of style in the layout css and found the above block. Then isolated the problem line. This process is an old program debugging technique. Get down to something that works, and then slowly heap the frills on until you find the error again. For simple problems, the last thing you added on is the most likely culprit. It's a tedious process, but it gets the job done. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] RE: Is it possible to auto increment an appended value?
Gorkfu wrote: : Thanks, Charles this code helps a lot. I understand how it works. You're welcome. : However its giving me one parse error with the line with a single : double quote as showen below. Is it possible to combine the 2 lines : below or escape the double quote? : : --- Code --- : : extrafield += ' value=?php echo $listcreate-' + padded_counter; : extrafield += '-EditValue ?/td/tr'; I only added the extra += statements to avoid line wrapping in the email. You could expand it all back out to how you had it or like this. extrafield += ' value=?php echo $listcreate-' + padded_counter + '-EditValue ?/td/tr'; But I don't know why there is a parse error on the double quotes. You might have picked up a stray character in the copy and paste from the email. Run your code through a lint program. I use this one for javascript: http://www.javascriptlint.com/ : I'm not familiar with escaping in javascript like in php, thanks. The escape character for javascript is the backslash (\). I looked it up a few days ago as I am spoiled by Perl and it's boatload of quoting operators. Javascript quoting is lie going back to Commodore BASIC. :( extrafield += ' value=\?php echo $listcreate-' + padded_counter; extrafield += '-EditValue ?\/td/tr'; HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: http://jquery.com/api/ page broken
Yansky wrote: : Hmm weird. I tried it in Opera on my machine and Firefox and IE7 on : another machine and it didn't work with any of them. I tried it again just now (7:57pm CST) with the cache disabled and, while it took a while to load, it still worked fine. Perhaps you are in the Twilight Zone. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Is it possible to auto increment an appended value?
[EMAIL PROTECTED] wrote: : Is it possible to auto increment the value on a variable that will be : appended? Yes. We would need to use a closure to preserve the value of the counter between clicks. The function in the $(document).ready section can act as the closure. : For example the bottom code I'm appending an extra row with a text : field to the table once the fields button is clicked. I want the data for every c# sign to count up from 1, 2, 3, etc... Any ideas : appreciated, thanks. : : Further Note: If the auto increment is possible, could I do it as 001, : 002, 003... Thanks. I included a function to do that. It relies on adding a repeat method to the built-in String object. : --- Code --- (function($) { // Add repeat method to String object String.prototype.repeat = function(n){ return new Array(n + 1).join(this); }; // Add leading_zeros method to jQuery $.leading_zeros = function(n, total_digits){ n = n.toString(); return '0'.repeat(total_digits - n.length) + n; }; })(jQuery); $(document).ready(function(){ // initialize the counter var counter = 0; $('#fields-button').click(function(){ // increment and pad the counter var padded_counter = $.leading_zeros(++counter, 3); // create the new field var extrafield = 'trtdList Item ' + padded_counter + '/tdtd'; extrafield += 'input type=text name=' + padded_counter + '' extrafield += ' id=' + padded_counter + '' extrafield += ' title= size=30 maxlength=255' extrafield += ' value=?php echo $listcreate-' + padded_counter; extrafield += '-EditValue ?/td/tr'; // add the new field to the table $('#fields').append(extrafield); }); }); : --- Code --- body button id=fields-buttonAdd Field/button table id=fields/table /body HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: http://jquery.com/api/ page broken
Yansky wrote: : The http://jquery.com/api/ page doesn't seem to be working for me. : When I click on a link, nothing happens. : : I'm using Firefox on Windows XP. Works for me on Firefox 2.0.0.11 and XP. It's a little slow loading at first. Clicking on a link slides down the detail. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: tabs display IE versus Firefox
MikeP wrote: : Hello. My tabs are functional in both IE and Firefox. However, the : look inside the tabs is different. : The words are appearing in white in IE and dark blue in Firefox. I've : tried removing all the other styles on my page and it didn't seem to : do anything. : : Could it have something to do with Unordered Lists? I notice you are using a Quirks mode DOCTYPE. Have you tried a Standards Compliance Mode DOCTYPE? Consider validating your page. You have mixed styles in your page. For example, some meta tags use xhtml markup while the page uses html 4.01 Transitional and there is no character encoding statement. The validator may help you with that. http://validator.w3.org/ Starting with a validated, Standards compliance mode page is your best bet to tracking down weird CSS problems. Quirks Mode (Current): !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN html lang=en head titleSoutheastern Equity Center/title Standards Compliance Mode (Suggested): !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=content-type content=text-html; charset=utf-8 titleSoutheastern Equity Center/title I tested your page with the above doctype/character encoding and corrected some of the link tags and got back to the blue (#27537a) tab color in IE 6. I suspect the problem is a Quirks mode problem. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: simplier, more unobtrusiv?
tlob wrote: : 1Page with 4 Divs : : div id=logo : LOGO -- click on that it fades away and go to div#content : /div : : div id=content : Homepage : Link Sandra-click, this div fades away, div#sandra is shown : Link Ahmed-click, this div fades away, div#ahmed is shown : /div : : div id=sandra : sandra : Link Home-click, this div fades away, div#content is shown : /div : : div id=ahmed : ahmed : Link Home-click, this div fades away, div#content is shown : /div [snip code] : : the links look like this: : a href=# class=sandraHome/a , etc... Can you show us the relevant part of the actual mark up you are using? HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Selecting listboxes that are in a table
MorningZ wrote: : Shouldn't : :: $(#ColumnEdit select) : : Provide me a jQuery array of those select boxes? No. $(#ColumnEdit select) should. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/
[jQuery] Re: Adding CSS-property therefore traveling the DOM - Problem.
Jayzon wrote: : div class=memberarea : div class=memberpic : a href=# : img src=the_image.jpg alt=Mr. X title=Mr. X / : /a : /div : div class=memberinfo : h4Mister X/h4 : pInfo 1/p : pInfo 2/p : pInfo 3/p : a href=## class=email[EMAIL PROTECTED]/a : /div : /div [snip] : I tried to do this with the following code: : : $(document).ready(function(){ : $(a.email).hover( : function () { : $(this).prev(a).css({margin-left:-210px}); : }, : function () { : $(this).prev(a).css({margin-left:-210px}).remove(); : } : ); : }); : [snip] : Since I'm totally new to jQuery, I tried to copy/paste the code from : the documentation and fit it to my needs. This didn't work out I : have no idea how to achieve the desired effect. According to the docs, .remove() is used to remove all matched elements from the DOM. CSS is not an element. It is a style. So you cannot use .remove() to remove a style. There are two problems with your example. First, there is no email class in the markup. So there will never be a match as you have the selector (a.email) written above. Also, there is only one anchor element in the document. There is no anchor previous to the anchor selected. So I assume you are looking for a hover over the image. This worked in my tests: $(document).ready(function(){ $( '.memberpic a img' ).hover( function () { $(this).parent().css( 'margin-left', '-210px' ); }, function () { $(this).parent().css( 'margin-left', '' ); } ); }); I could have used a shorter selector ('memberpic img'), but the selector above indicates which element is the parent of the img element. Note that if your image is 210 pixels or less then the second function will be triggered as the image moves to the left. A simpler approach might be to select the anchor in the first place. The :has() selector comes in handy here. This allows future expansion of the div with additional text without breaking this selector. $( '.memberpic a:has(img)' ).hover( function () { $(this).css( 'margin-left', '-210px' ); }, function () { $(this).css( 'margin-left', '' ); } ); HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 http://www.clarksonenergyhomes.com/wordpress/about/