[jQuery] Re: How to Get Div from IFrame

2009-11-20 Thread mkmanning
No. Cross domain also applies to different sub-domains, protocols, and
ports.

On Nov 20, 11:17 am, webspee...@gmail.com webspee...@gmail.com
wrote:
 Outside of my domain, I can understand. I'll have to hold off for a
 bit then.

 Although the page will be remote, it will be accessible 
 byhttp://search.mydomain.com. Once it's accessible as a sub domain',
 will I then have access to the page's elements?

 On Nov 16, 7:55 am, Liam Byrne l...@onsight.ie wrote:



  You can't do this if the content of the iFrame is from a different
  server / domain.

  e.g. if it's not your content, then you can't get at it this way in
  order to show it in your page; you can only display the iframe as the
  owner intended.

  L

  webspee...@gmail.com wrote:
   When I try it, I get this error:

   Error: Permission denied for http://www.myurl.com to get property
   HTMLDocument.nodeType from http://remoteurl:.
   Source File:http://www.myurl.com/js/jquery/jquery.js
   Line: 2216

   Here is the line of JS being used.

   $(#eseSearchRight).html($('#searchFrame').contents().find
   ('.recordHeader').html());

   On Nov 5, 4:17 pm, Michel Belleville michel.bellevi...@gmail.com
   wrote:

   $('#canvas_frame').contents().find('#my_div');

   To seek an id use #, to seek inside a div use .contents().

   Plus, refrain from using iframe, this is almost as bad as using frame and
   almost never worth it. AJAX is good for you instead of shitty iframes.

   Michel Belleville

   2009/11/5 Danish engrdanishsid...@gmail.com

   I have a page with multiple Frames and Division, Now I am trying to
   extract one div having id=my_div from iframe with Id =
   canvas_frame but I am fail to do so, Nor I am getting iframe neither
   Division in iframe.
   I tried all these selectors but always null returns although they are
   in page:
   1) $(my_div);
   2) $(my_div,canvas_frame);
   3) $(canvas_frame,content.document);
   4) $(canvas_frame);
   5)  var $frame = $(canvas_frame,content.document);
       var $div = $(my_div,$frame);

   I am able to do this with Pure JavaScript but due to some reasons I
   want to use JQuery Library, Any help will be highly appreciated.
   

   No virus found in this incoming message.
   Checked by AVG -www.avg.com
   Version: 8.5.425 / Virus Database: 270.14.63/2500 - Release Date: 
   11/13/09 07:54:00


[jQuery] Re: :gt and :lt don't accept variable as a parameter?

2009-11-17 Thread mkmanning
Try  $('#filterlist_wrapper ul li:gt('+left_col+')')

On Nov 17, 3:35 pm, Magnificent
imightbewrongbutidontthin...@gmail.com wrote:
 It should read:

  I'm storing my counts in variables, but it doesn't look like :gt
  and :lt can accept a VARIABLE value as it's parameter.

 It works when I put in, say :gt(44), but not :gt(left_col) or lt:
 (right_col) when those variables are numbers.


[jQuery] Re: cannot insert html into DIV

2009-11-04 Thread mkmanning
If you used Andrew's example, then you added a jQuery object to the
canvasClasses array. Calling innerHTML on a jQuery object won't work.
Try canvasClasses[0].html('htmlhere')

On Nov 4, 3:35 pm, shaf shaolinfin...@gmail.com wrote:
 That doesnt work either.

 On Nov 4, 11:28 pm, Andrew Tan afh...@gmail.com wrote:



  You have to supply the canvas object as a parameter to the push function to
  add it to the array.

  canvasClasses.push($(this));

  On Thu, Nov 5, 2009 at 10:16 AM, shaf shaolinfin...@gmail.com wrote:
   Hi Guys,

   I have several .class DIVs I want to manipulate. I have retrieved them
   using the following code:

          var canvasClasses = new Array();
          $(.canvas).each(function() {
                  canvasClasses.push()
          });

   I am now trying to insert some HTML into the DIVs but its not working:

   canvasClasses[0].innerHTML = htmlhere;

   Any ideas on why its not working ?


[jQuery] Re: Simple question. my query isnt working

2009-10-30 Thread mkmanning
Where are you including the scripts? If they're in the head, then you
need to wrap your selector in a document.ready function, as the script
is running before your div exists in the DOM.

Try including your scripts just before the closing body tag.

On Oct 30, 7:44 pm, numerical25 numerica...@aol.com wrote:
 I just started on a book and before I can get started I am already stuck.
 Here is what ive done

 1. Ive added jquery to my server and I included it in my html. I check my
 source code in browser and it shows that it's there. I have version 1.3.2

 2. I added this line of code
 script src=jquery.js/script
 script type=text/javascript
         $('#go').html(I have added some text to an element);
 /script

 3. In my body tag I added this
 div id=go

 And nothing is happening. I tried calling the class and the id.
 --
 View this message in 
 context:http://old.nabble.com/Simple-question.-my-query-isnt-working-tp261394...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: Select the inverse of what you're looking for

2009-10-30 Thread mkmanning
Try this:

$(tr:not(:contains(Brown))).css(background-color, Red);

On Oct 30, 12:58 pm, Aaron Gusman ict.aarongus...@gmail.com wrote:
 I have a table with 2 columns and four rows.  I am currently able to
 highlight the row which contains a specific piece of text.  But what I
 want to do is to highlight the rows that DO NOT have that piece of
 text.  Here's the code:

 This line highlights the row that contains a cell with the text
 Brown:
         var found = $(tr:has(td:contains('Brown'))).css(background-color,
 Red);

 However, I do not want to highlight the row with the text but all the
 others..so I tried this:
         var found = $(tr:has(td:contains('Brown')));
         $(tr:not(found)).css(background-color, Red).css(background-
 color, Red);
 I thought the :not filter was supposed to invert the selection however
 this does not work..all rows get highlighted.

 Were am I wrong??  And how can I do this?  Here's the HTML just in
 case you want to try it.

 table cellspacing=0 cellpadding=0
   tr
     thEnglish/th
     thItalian/th
   /tr
   tr
     tdWhite/td
     tdBianco/td
   /tr
   tr
     tdYellow/td
     tdGiallo/td
   /tr
   tr
     tdBrown/td
     tdMarrone/td
   /tr
   tr
     tdBlack/td
     tdNero/td
   /tr
 /table

 Thanks


[jQuery] Re: Simple problem

2009-10-29 Thread mkmanning
var panelID =  panel_ + $(input).val();

You're problem is the selector; look at it for a second to see why it
won't work (think about what exactly it's selecting). If you want the
value of the button that was clicked, just reference it with 'this',
as in

var panelID =  panel_ + this.value;

or you could use its ID:

var panelID =  panel_ + this.id;

You could wrap it like this:

var panelID =  panel_ + $(this).val(); //or $(this).attr('id')

but it's overkill.

On Oct 29, 3:56 pm, AlChuck alan.oeh...@alanoehler.com wrote:
 Hello, I'm new to using jQuery. I was motivated by wanting to put some
 panels on an ASP.NET website which would display additional info if a
 link or button was clicked. I found a simple tutorial and mimicked
 that and it works fine, but uses the specific ID of the hyperlink to
 trigger the action. My page needs a list of items, and if you click on
 one, extra information appears right below the item. So what I want to
 do is capture clicks on any link, read the ID, and then use the ID to
 identify the ID of the related asp:Panel element.

 Here's the starting point:

    script type=text/javascript
             $(function() {
                 $(#myButtonID).click(function(evt) {
                     evt.preventDefault();
                     $('#myPanelID').toggle('fast');
                 });
             });
     /script

 If you click on the button rendered thusly:

     input id=myButtonID type=button value=Hide/Show /

 The panel with id=myPanelID is toggled (the CSS defines it so that
 display is set to none by default.

 But I want a list of these panels and buttons on my page, so I want
 the code to be able to do this for any of the buttons I click.

 It also works if instead of the button with the specific ID
 myButtonID I change

 $(#myButtonID).click(function(evt)

 to

 $(input).click(function(evt)

 My impression is that this will cause the code to trigger if any input
 element on the page is clicked, which is the first step to what I want
 to do. My notion is that I can then get the value of the clicked
 button and use that value to identify which panel to animate.

 One of the FAQs on the jQuery site says I can get the value of the
 button thusly:

 var mybuttonval = $(input).val();

 Then I could use a simple naming convention and use that value to
 identify the Panel I want to animate. For example, if my button had
 the value ACME_widget-mach1 I could set the Panel I want to show
 text in to panel_ACME_Widget-mach1

 So I rewrote my code as follows:

     script type=text/javascript

             $(function() {
                 $(input).click(function(evt) {
                     var panelID =  panel_ + $(input).val();
                     evt.preventDefault();
                     $(panelID).toggle('fast');
                 });
             });
     /script

 It appeared to work just like I hoped... until I put in a second
 button/panel pair, with button ID= ACME_widget-mach2 and panel ID=
 panel_ACME_widget-mach1. What happens is, regardless of which button I
 click, only the first panel, the one with ID=panel_ACME_widget-mach1
 is toggled.

 It's as if when any button is clicked, the value I am getting is the
 value of the first button in the collection. I put in an alert box
 right after declaring the variable to test this:

                     alert(panelID);

 and sure enough, the value that displays is the value assigned to the
 first of these buttons on the page.

 So what am I doing wrong here? How can I get the value of the button
 that is actually clicked?

 Thanks!

 Alan


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Well, if you just want to loop through the array to change the
background color, you don't really need toggle then. Try this:

 $(#item_list  li  div  a).click(function(){
  var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
255)','rgb(128, 0, 128)'],
  bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
  $(this).css('background-color',arrValues[bgcolor===arrValues.length?
0:bgcolor]);
});

disclaimer: just wrote it inside Firebug's console, so haven't tested
it outside that...

On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote:
 Thanks, had a good read, figured it out in part.
 Now I'm stuck trying to introduce an array to do my bidding ...
 Example below.

 The array is an example of how I want to loop through to use those
 values.
 Underneath is the perfect code for clicking an Anchor and changing its
 BGcolour differently each time.

 Any ideas?

 $(document).ready(
         function(){
                 var arrValues = ['green','aqua','blue','purple'];

                 $(#item_list  li  div  a).toggle(
                 function(){
                         $(this).css('background-color', 'green');
                 }, function() {
                         $(this).css('background-color', 'aqua');
                 }, function() {
                         $(this).css('background-color', 'blue');
                 }, function() {
                         $(this).css('background-color', 'purple');
                 });

 });

 On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote:



  .toggle() allows you to rotate through multiple functions, you might
  want to check it out in the 
  docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...

  On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote:

   I've got one for ya, JQuery and Ajax.

   I want to have a button image, let's stay it's inactive state it's a
   grey circle, when someone clicks it once, it'd change to a blue circle
   (update associated DB field to blue), click it again and it becomes
   a red circle (update the DB field to red) and so on. So users keep
   clicking until they get the right color, then move on to the next
   one.

   I've seen something similar in Google where you can star emails with
   different stars.

   Any idea how you'd do this?
   It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Yeah, the snippet I wrote updates the color; you can add an ajax call
to update your db as well, if the value your updating in the db is the
color, or else the value is in an array that's indexed the same.

On Oct 22, 12:10 am, The Danny Bos danny...@gmail.com wrote:
 For each click of the DIV I'm hoping to change the BackgroundColor,
 make some updates in the Database (depending on which array selection
 it's on) and that's about it.

 So, the first click of the DIV = Change BG to 'green', update DB
 field to 'XXX'
 the second click of the DIV = Change the BG to 'aqua', update DB
 field to 'YYY'
 the third click ... etc

 Know what I mean?

 On Oct 22, 6:04 pm, mkmanning michaell...@gmail.com wrote:



  Well, if you just want to loop through the array to change the
  background color, you don't really need toggle then. Try this:

   $(#item_list  li  div  a).click(function(){
    var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
  255)','rgb(128, 0, 128)'],
    bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
    $(this).css('background-color',arrValues[bgcolor===arrValues.length?
  0:bgcolor]);

  });

  disclaimer: just wrote it inside Firebug's console, so haven't tested
  it outside that...

  On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote:

   Thanks, had a good read, figured it out in part.
   Now I'm stuck trying to introduce an array to do my bidding ...
   Example below.

   The array is an example of how I want to loop through to use those
   values.
   Underneath is the perfect code for clicking an Anchor and changing its
   BGcolour differently each time.

   Any ideas?

   $(document).ready(
           function(){
                   var arrValues = ['green','aqua','blue','purple'];

                   $(#item_list  li  div  a).toggle(
                   function(){
                           $(this).css('background-color', 'green');
                   }, function() {
                           $(this).css('background-color', 'aqua');
                   }, function() {
                           $(this).css('background-color', 'blue');
                   }, function() {
                           $(this).css('background-color', 'purple');
                   });

   });

   On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote:

.toggle() allows you to rotate through multiple functions, you might
want to check it out in the 
docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...

On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote:

 I've got one for ya, JQuery and Ajax.

 I want to have a button image, let's stay it's inactive state it's a
 grey circle, when someone clicks it once, it'd change to a blue circle
 (update associated DB field to blue), click it again and it becomes
 a red circle (update the DB field to red) and so on. So users keep
 clicking until they get the right color, then move on to the next
 one.

 I've seen something similar in Google where you can star emails with
 different stars.

 Any idea how you'd do this?
 It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-22 Thread mkmanning

Something like this (untested):

var arrValues = ['c1','c2','c3','c3'],
cnameIndex = $.inArray(this.className,arrValues)+1;
this.className = cnameIndex===arrValues.length?0: cnameIndex ];

if you can live with only one classname, otherwise you'll have to add
code to remove the old classname from arrValues and then add the new
class with addClass.

Basically all this is doing is getting the current value of a given
property, such as background-color, finding its index in the arrValues
array, incrementing that by one and then setting the new value to the
element in the array with the incremented index. If the index is at
the end of the array, it resets to 0.

On Oct 22, 4:39 am, The Danny Bos danny...@gmail.com wrote:
 Thanks so much man,
 That'll work well ... One more thing, how would I change it to point
 to classes instead of direct colours?

 var arrValues = ['c1','c2','c3','c3'],

 Thanks again,

 On Oct 22, 6:27 pm, mkmanning michaell...@gmail.com wrote:



  Yeah, the snippet I wrote updates the color; you can add an ajax call
  to update your db as well, if the value your updating in the db is the
  color, or else the value is in an array that's indexed the same.

  On Oct 22, 12:10 am, The Danny Bos danny...@gmail.com wrote:

   For each click of the DIV I'm hoping to change the BackgroundColor,
   make some updates in the Database (depending on which array selection
   it's on) and that's about it.

   So, the first click of the DIV = Change BG to 'green', update DB
   field to 'XXX'
   the second click of the DIV = Change the BG to 'aqua', update DB
   field to 'YYY'
   the third click ... etc

   Know what I mean?

   On Oct 22, 6:04 pm, mkmanning michaell...@gmail.com wrote:

Well, if you just want to loop through the array to change the
background color, you don't really need toggle then. Try this:

 $(#item_list  li  div  a).click(function(){
  var arrValues = ['rgb(9, 128, 0)','rgb(0, 255, 255)','rgb(0, 0,
255)','rgb(128, 0, 128)'],
  bgcolor = $.inArray($(this).css('background-color'),arrValues)+1;
  $(this).css('background-color',arrValues[bgcolor===arrValues.length?
0:bgcolor]);

});

disclaimer: just wrote it inside Firebug's console, so haven't tested
it outside that...

On Oct 21, 10:14 pm, The Danny Bos danny...@gmail.com wrote:

 Thanks, had a good read, figured it out in part.
 Now I'm stuck trying to introduce an array to do my bidding ...
 Example below.

 The array is an example of how I want to loop through to use those
 values.
 Underneath is the perfect code for clicking an Anchor and changing its
 BGcolour differently each time.

 Any ideas?

 $(document).ready(
         function(){
                 var arrValues = ['green','aqua','blue','purple'];

                 $(#item_list  li  div  a).toggle(
                 function(){
                         $(this).css('background-color', 'green');
                 }, function() {
                         $(this).css('background-color', 'aqua');
                 }, function() {
                         $(this).css('background-color', 'blue');
                 }, function() {
                         $(this).css('background-color', 'purple');
                 });

 });

 On Oct 22, 3:46 am, mkmanning michaell...@gmail.com wrote:

  .toggle() allows you to rotate through multiple functions, you might
  want to check it out in the 
  docs:http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...

  On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote:

   I've got one for ya, JQuery and Ajax.

   I want to have a button image, let's stay it's inactive state 
   it's a
   grey circle, when someone clicks it once, it'd change to a blue 
   circle
   (update associated DB field to blue), click it again and it 
   becomes
   a red circle (update the DB field to red) and so on. So users 
   keep
   clicking until they get the right color, then move on to the next
   one.

   I've seen something similar in Google where you can star emails 
   with
   different stars.

   Any idea how you'd do this?
   It's got me stumped.


[jQuery] Re: Click multiple times, different states, saves different data to DB (confusing?)

2009-10-21 Thread mkmanning

.toggle() allows you to rotate through multiple functions, you might
want to check it out in the docs: 
http://docs.jquery.com/Events/toggle#fnfn2fn3.2Cfn4.2C...

On Oct 21, 2:58 am, The Danny Bos danny...@gmail.com wrote:
 I've got one for ya, JQuery and Ajax.

 I want to have a button image, let's stay it's inactive state it's a
 grey circle, when someone clicks it once, it'd change to a blue circle
 (update associated DB field to blue), click it again and it becomes
 a red circle (update the DB field to red) and so on. So users keep
 clicking until they get the right color, then move on to the next
 one.

 I've seen something similar in Google where you can star emails with
 different stars.

 Any idea how you'd do this?
 It's got me stumped.


[jQuery] Re: Creating a Function based on text argument

2009-10-21 Thread mkmanning

Operations like .val() return a string, so If you need to extend a
string you have to use String.prototype:

String.prototype.slug = function(){return this.trim().etc...}

The way you've done it works, but in the same way 'trim' works, i.e.
you have to pass the string to the function:

$.slug($('#form_element').val());

On Oct 21, 3:05 pm, Kerry tiamat2...@gmail.com wrote:
 I've been looking around and besides my best efforts I haven't been
 able to figure it out.

 All the function extending I see extends on an _object_.

 I want to extend on a string.

 /**
  * Returns a slug version of a string
  */
 jQuery.extend ({
         slug: function( text ) {
                 return text.trim().toLowerCase().replace( /[^-a-zA-Z0-9\s]/g,
 '' ).replace( /[\s]/g, '-' );
         }

 });

 I want to be able to do something like:

 $('#form_element').val().slug();

 The above does not work. I even tried modifying the 'trim' function in
 jQuery core to include the rest of the enhancements, but it didn't
 work.


[jQuery] Re: Get parameters from URL

2009-10-17 Thread mkmanning

There are several plugins:

http://plugins.jquery.com/project/parseQuery


On Oct 17, 7:41 am, ReynierPM rper...@uci.cu wrote:
 Hi every:
 It's possible to get values from URL with jQuery like PHP? For example
 suppose you have this URL: form.html?s=okval=rperezm. In PHP is simple:
 [code]
   echo $_GET['s']; // return ok
   echo $_GET['val']; // return rperezm
 But I don't know if this is possible in Javascript and also with jQuery.
 Can any body guide me on this?
 Cheers and thanks in advance
 --
 ReynierPM


[jQuery] Re: $('a:link') Selector?

2009-10-17 Thread mkmanning

A couple things. First off, the syntax you're using won't get you the
anchor's color:

$('a:link',this).css('color');

This is a shortcut for:

$(this).find('a:link').css('color')

which basically means find the anchors inside this anchor. If you want
the anchor's original color, just use:

$(this).css('color')

Getting the color that is set by the CSS pseudo :hover is another
problem. To get that via JavaScript you'd have to loop through the
stylesheets cssRules and do a regex match.

Michael

On Oct 17, 10:59 am, Steven html...@gmail.com wrote:
 Hello,

 I'm trying to make a basic, dynamic link color fader. Since I have
 multiple link colors for different classes and divisions and such, I'm
 trying to make it dynamic. To do so I need to grab the original
 color and the hover color. Here is my code:

 // Fading links
 $('a').hover(
         // Over
         function(){
                 var original_cl = $('a:link',this).css('color');
                 var fade_cl = $('a:hover',this).css('color');
                 alert('Original color: '+original_cl+'; Fade color: 
 '+fade_cl);
         },
         // Out
         function(){

         }
 );

 Both colors come as undefined; experimentation tells that using
 a:link or a:hover as the selector is invalid. How can I grab these
 colors in context?

 Thanks,
 Steven


[jQuery] Re: How to obtain Object (key) names?

2009-10-17 Thread mkmanning

The problem with something like the desired approach:

if (option.name == Option1) {

is that 'name' is a valid key, so if you had an object like

{'name':'john'}

option.name would equal 'john' (same problem if you tried option.key).

Also, though your example only has one key, an object can have mutiple
keys.

Easiest way is just loop through the keys (fast since there's only one
key/value pair in your object):

$.each(JSON.options, function(i, option) {
   for(k in option) {
if(k === 'Option1'){
  // do something
}
   }
});



On Oct 16, 5:41 pm, Frederic Laruelle frederic.larue...@gmail.com
wrote:
 Hi,

 I;m looking for a way to obtain key names from a JSON object:
 eg
 options: [
                 {Option1 : [Value1, Value2]},
                 {Option2 : [Value3, Value4]},
                 {Option3 : [Value5, Value6]}
                 ]

 so, i'd like to consume this JSON in a way similar to this:
 $.each(JSON.options., function(i, option) {
         if (option.name == Option1) {
                        // do something
                        }

 });

 Prototype seems to have a keys method which would achieve what i'm
 looking for.
 There are also a few pages which attempt to address the issue with
 JQuery, such as:http://snipplr.com/view/10430/jquery-object-keys/
 However i was only able to retrieve the numerical index of the array
 elements using these methods (vs their name).

 Any help appreciated.

 Tks!

 Fred~


[jQuery] Re: How to Sort an Unordered List - TinySort

2009-10-14 Thread mkmanning

Never used the plugin, but doing the sort you want is fairly simple:

$('#refmenu').click(function(){
  var sorted = $.makeArray($('#listli')).sort(function(a,b){
return ($(a).children('a').attr('title')  $(b).children('a').attr
('title')) ? -1 : 1;
  });
  $('#list').html(sorted);
});

HTH


On Oct 12, 5:55 am, tfat tony.fatou...@gmail.com wrote:
 Hi,

 I have the following DOM structure (unordered list), that I would like
 to sort on the a href tag name using jQuery – specifically the
 TinySort plug-inhttp://plugins.jquery.com/project/TinySort

 Structure is as follows:

 div id=refmenu
 ul id=list
 lia title=Google href=Google/a/li
 lia title=Apple href=Apple/a/li
 lia title=IBM href=IBM/a/li
 lia title=Yahoo! href=Yahoo!/a/li
 lia title=Hotmail href=Hotmail/a/li
 /ul
 /div

 I have tried the following but to no avail, i.e.:
 $(div#refmenuul#listli).tsort(a[title],{orderby:title});

 Based on this, I am obviously trying to sort on the title attribute.

 Any help would be great.

 Other questions, do I need to make this call within the document.ready
 () or can I just perform this call within a normal javascript
 function?

 Thanks.


[jQuery] Re: Selecting all last cells in all rows?

2009-10-12 Thread mkmanning

$('td:last-child')

On Oct 12, 9:45 am, MorningZ morni...@gmail.com wrote:
 with this html:

 table
     tbody
         tr
              td.../tdtd.../tdtd.../td
         /tr
         tr
              td.../tdtd.../tdtd.../td
         /tr
         tr
              td.../tdtd.../tdtd.../td
         /tr
     /tbody
 /table

 what would the selector be to get all the *last* td's in each row ?

 I'm looping through the rows, and then getting the last td in each
 row and doing what I need to do, but I recall an earlier topic where
 it was a single selector to get all those last cells in one shot...
 damned if i can find it though...  i do believe :last-child was
 involved

 Thanks in advance


[jQuery] Re: possible to empty file input in form with .click or .focus ?

2009-10-12 Thread mkmanning

You could replace the file input when the URL field is focused:

$('#fu').replaceWith('input id=fu type=file /');

where #fu is the file input.

On Oct 12, 11:53 am, amuhlou amysch...@gmail.com wrote:
 hmm yeah, I did a quick google search and it appears that allowing you
 to access a file input's value attribute would pose a security issue.

 I found a solution but the code isn't exactly 
 prettyhttp://gusiev.com/2009/04/clear-upload-file-input-field/

 On Oct 12, 6:43 pm, captaincarp harry.wi...@gmail.com wrote:



  Yeah this is what I've been trying,

  i think maybe different rules apply for file inputs perhaps?

  amuhlou wrote:

   Try:

   $('#input_id').focus(function(){
           $(this).attr(value,);
   });

   On Oct 12, 5:59 pm, captaincarp harry.wi...@gmail.com wrote:
   My image upload form has a choice of either upload image by entering url
   or
   by browsing for a file,

   I'm trying to empty the file-input input if you focus on the url-input.

   I've tried bother these events on click/blur  but neither seem to work
   like
   they would for a checkbox or text input...

   $('#input_id').empty();
   $('#input_id').attr('value', '');

   any ideas would be help my head!
   --
   View this message in
   context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
   Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  View this message in 
  context:http://www.nabble.com/possible-to-empty-file-input-in-form-with-.clic...
  Sent from the jQuery General Discussion mailing list archive at Nabble.com.


[jQuery] Re: something amiss with json call/file

2009-09-14 Thread mkmanning

It's not jQuery, it's just basic same origin policy. From your
example, the calls are cross domain because you were using
'www.pomona.edu' in the getJSON call from 'pomona.edu'. Those are
different hosts.

On Sep 14, 10:16 am, roryreiff roryre...@gmail.com wrote:
 The problem ended up being my call to .getJson and something about how
 jQuery was recogzing the url as being cross domain. I changed the call
 to the file to be relative and it is working now. Thanks for the help.

 On Sep 11, 4:57 pm, Scott Haneda talkli...@newgeo.com wrote:



  Maybe your use of appendTo is wrong, I just did this test:

  $.getJSON(http://www.pomona.edu/dev/home/spotlight.json;,
  function(data){
          $.each(data.items, function(i, item){
                  $(div).append(i);

                  });
          });

  div id=images/div

  I got 01234, so the index of each item in your JSON.  With that, you  
  know your JSON is ok, and you need to look at what appendTo is not  
  working.

  Sorry I can not be of more help, this is about day 2 of Jquery for me.

  On Sep 11, 2009, at 3:56 PM,roryreiffwrote:

   I have the following code:

          // pull in json feed and inject panes into page
      $.getJSON(http://www.pomona.edu/dev/home/spotlight.json;,
          function(data){
              $.each(data.items, function(i,item){
                              $('div 
   class=\pane\/div').appendTo('#spotlight-panes');
                      });
              });

   and I cannot figure out what is going wrong. As you can see, I am not
   even trying to do anything yet with the json data, but assuming that I
   should still be seeing some divs injected into the DOM. Wondering if
   there is something wrong with my JSON file? Any help is
   appreciated...I just can't figure out what is going on! Code in effect
   here:http://pomona.edu/dev/home/index.aspThanks,

  --
  Scott * If you contact me off list replace talklists@ with scott@ *


[jQuery] Re: Accessing Elements after adding them with Append

2009-09-02 Thread mkmanning

Use .live()

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


On Sep 2, 1:51 am, Daniel battlew...@googlemail.com wrote:
 Hi There,

 I'm having trouble accessing some Elements with jQuery after I created
 them and added them to the HTML. I want to add some Checkboxes to my
 Site as soon as the user clicks another Checkbox. That works just
 fine. But if the user clicks on one of these added checkboxes, i want
 an event to trigger, too. For starters, i just want to alert a
 message. But this doesnt happen.

 Here's my code:

 function load(katstring) {
         var mykats = '';
         $('div#kategorien input:checkbox:checked').each(function() {
                 mykats += mykategorien[]= + $(this).attr('id').substr(4);
         });
         $.post('ajaxfunctions.php', 'function=updateCategories', function
 (data){
                 var kattext = '';
                 kattext += 'ul';
                 for (index in data) {
                         kattext += 'liinput type=checkbox 
 name=category[]
 value='+data[index]+' /'+data[index]+'/li';
                 }
                 kattext += '/ul';

                 $('div#categories div.select').html(kattext);
         },'json');

 }

 $('div#categories div.select ul li input').click( function() {
         alert(clicked);

 });

 So on click of the new, added checkboxes, i want to alert clicked.
 Nothing More. But that just won't happen. First, i figured the problem
 lies in just adding some html Text and not properly adding the
 elements to the DOM Tree. So i tried something like this:

 function load(katstring) {
         var mykats = '';
         $('div#kategorien input:checkbox:checked').each(function() {
                 mykats += mykategorien[]= + $(this).attr('id').substr(4);
         });
         $.post('ajaxfunctions.php', 'function=updateCategories', function
 (data){
                 var cul = document.createElement('ul');
                 for (index in data) {
                         var cli = document.createElement('li');
                         var cinput = document.createElement('input');
                         var ctext = document.createTextNode(data[index]);
                         cli.appendChild(cinput);
                         cli.appendChild(ctext);
                         cul.appendChild(cli);
                 }
                 document.getElementById('categories').appendChild(cul);
         },'json');

 }

 $('div#categories ul li input').click( function() {
         alert(clicked);

 });

 In this Code all the Element Attributes are missing but I think you
 get what i was trying. ;) So, now I think the Elements are added
 properly to DOM tree. But still, when I click on one of the added
 input Elements, nothing happens.

 What am I doing wrong? How can i get jQuery to recognize the Elements
 I added?

 Can you please help? Thanks a lot.

 battlewizz


[jQuery] Re: JQuery Form - Ajax - Please HELP ! ! ! ! ! ! !

2009-09-02 Thread mkmanning

You could just add name attributes to the text fields (e.g. input
type=text id=item_01 name=item_01 class=item_field
value=123/ ) and then just use data:$('#myForm').serialize().

That will give you a querystring like:
item_01=123item_02=456item_03=789 (you can't pass an array to
'data', it expects an object or a string).


On Sep 2, 10:43 am, huntspointer2009 huntspoin...@gmail.com wrote:
 ///Comment:
 Can someone help me do the following:
 create a function that collects ALL of the form's text field's Values,
 along with their corresponding ID, and create an Array like this:
 Example: var dataString = (item_01=123, item_01=456, item_01=789)

 then take the 'dataString' Array, and send it to a Server via Ajax,
 whenever I click the 'Submit Button'

 Please Note:
 that as new items are created/added to the form,
 the 'Submit Button' must be able to continue submitting the
 'dataString' Array to server via Ajax
 whenever I click it.

 // HTML Code :
 form id=myForm action=receive_items.php method=post
     ul
         li
             labelItem_01/label
             input type=text id=item_01 class=item_field
 value=123/
             input type=submit value=delete button
 class=button_delete/
         /li
         li
             labelItem_02/label
             input type=text id=item_02 class=item_field
 value=456/
             input type=submit value=delete button
 class=button_delete/
         /li
         li id=item_03
             labelItem_03/label
             input type=text id=item_03 class=item_field
 value=789/
             input type=submit value=delete button
 class=button_delete/
         /li
     /ul
     input type=submit value=Submit Button class=button_submit/
 /form

 // JQuery Code:
 $(document).ready(function(){
         $('.button_submit').click(function(){
                         $.ajax({
                                 type: POST,
                                 url: receive_items.php,
                                 data: dataString,
                                 success: function(){
                                 alert(The Data was successfully sent to 
 server:);
                                 }
                         });
         });

 });

 - Thank you very much (in Advance)


[jQuery] Re: Do events remain is memory when element is removed from DOM?

2009-09-01 Thread mkmanning

.remove() will also remove all event handlers and internally cached
data
http://docs.jquery.com/Manipulation/remove#expr

On Sep 1, 4:18 pm, roydukkey royduk...@gmail.com wrote:
 Is it necessary to unbind events from elements before removing them.
 As like the following:

 $(#list).find(li).unbind(hover).remove();
 $(#list).html(List of New LI's);

 I'm building a plugin, and I want to know if the events listners will
 remain in memory, as code similar to the above will run every 5
 seconds or so.


[jQuery] Re: Replacing like items

2009-08-31 Thread mkmanning

Play around with this:
$('input[value*=||]').change(function(){
var $this = $(this),val = $this.val().split('||')[1];
if($this.is(':checked')){

$this.removeAttr('disabled').siblings('input[value$='+val+']').attr
('disabled','disabled');
} else {
$this.siblings('input[value$='+val+']').removeAttr('disabled');
}
});


What you're trying to do is make checkboxes behave like radio buttons,
so why not just use radios, as they're far more appropriate for
selecting only one of several choices?




On Aug 30, 12:44 pm, Steffan A. Cline stef...@hldns.com wrote:
 I have a form of data I am working on where I may have *nearly* the same
 thing appear with a checkbox appear multiple times.

 For example:

 input type=checkbox name=blah value=widget1||123456
 input type=checkbox name=blah value=widget2||123456
 input type=checkbox name=blah value=widget3||123456
 input type=checkbox name=blah value=widget4||123456
 input type=checkbox name=blah value=widget5||123456

 So, if checkbox #1 (widget1) is checked, it will either disable all other
 ones containing the sku 123456 OR replace the others in the form having sku
 123456 with an image of a sort.

 Is there a way to select this without iterating through every checkbox in
 the form and looking at it's value?

 Thanks

 Steffan

 ---
 T E L  6 0 2 . 7 9 3 . 0 0 1 4 | F A X  6 0 2 . 9 7 1 . 1 6 9 4
 Steffan A. Cline  
 stef...@execuchoice.net                             Phoenix, 
 Azhttp://www.ExecuChoice.net                                 USA
 AIM : SteffanC          ICQ : 57234309
 YAHOO : Steffan_Cline   MSN : stef...@hldns.com
 GOOGLE: Steffan.Cline             Lasso Partner Alliance Member
 ---


[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-28 Thread mkmanning

$.makeArray() converts the elements returned from the jQuery selector
to an actual array. Arrays in JavaScript have a sort method, into
which you can pass an optional sort function (by default the members
of the array are sorted lexicographically). The members of this array
are the span elements, and their text content (via .text()) is used
for the comparison.

https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/sort


On Aug 28, 2:34 am, Audrey A Lee audrey.lee.is...@gmail.com wrote:
 hmm...
 okay.

 I think I understand this (a little-bit).

 It reminds me of how I sort objects in an array in Ruby.

 The way I do that is I need to write a method which compares object-a
 to object-b.

 So if each object has attributes like name, address, phone, age,
 income, I need to decide which attribute will be used in the
 comparison.

 That's the 1st idea.

 The 2nd idea is that I need to specify Ruby syntax.

 To me it is a 1 line black box.  But it does work and it is easy for
 me to memorize.

 I use a Ruby built-in-operator which contains NO LETTERS; here it is:
 =

 So the Ruby expression:
 8 = 9
 returns -1
 and
 9 = 8
 returns 1

 So my Ruby method to compare object-a to object-b might be very simple
 to write:

 def compare_em(obja, objb)
   return obja.name = objb.name
 end

 Or I might write this to make use of the same operator syntax:

 def =(obja, objb)
   return obja.name = objb.name
 end

 If I work with the above syntax so it can live in the class of obja
 and objb,
 I might have this:

 class Person
   def =(objb)
     return self.name = objb.name
   end
 end

 Then, I could create a array of persons:

 person1.name = Fred
 person2.name = Alan
 person3.name = Sally

 persons = [person1,person2,person3]

 And the expression:
 persons.sorted

 would give me:

 [person2,person1,person3]

 Using Ruby to understand JavaScript is a strange path, but my mind
 does what it can.

 -Audrey

 On Aug 27, 4:49 pm, mkmanning michaell...@gmail.com wrote:



  I'm gonna go out on a limb and assume you want them sorted
  alphabetically, by span content:

  var sorted = $.makeArray($('#names span')).sort(function(a,b){
  return ($(a).text()  $(b).text()) ? -1 : 1;});

  $('#names').html(sorted);

  On Aug 25, 9:14 pm, Audrey Lee audrey.lee.is...@gmail.com wrote:

   Hello,

   Assume I have 3 span-elements:

   div id=names
     span id=s1Fred/span
     span id=s2Alan/span
     span id=s3Sally/span
   /div

   Is there a jQuery way to sort them so I get this:

   div id=names
     span id=s2Alan/span
     span id=s1Fred/span
     span id=s3Sally/span
   /div

   ??

   -Audrey


[jQuery] Re: Is there a jQuery way to sort span-elements?

2009-08-27 Thread mkmanning

I'm gonna go out on a limb and assume you want them sorted
alphabetically, by span content:

var sorted = $.makeArray($('#names span')).sort(function(a,b){
return ($(a).text()  $(b).text()) ? -1 : 1;
});
$('#names').html(sorted);


On Aug 25, 9:14 pm, Audrey Lee audrey.lee.is...@gmail.com wrote:
 Hello,

 Assume I have 3 span-elements:

 div id=names
   span id=s1Fred/span
   span id=s2Alan/span
   span id=s3Sally/span
 /div

 Is there a jQuery way to sort them so I get this:

 div id=names
   span id=s2Alan/span
   span id=s1Fred/span
   span id=s3Sally/span
 /div

 ??

 -Audrey


[jQuery] Re: Getting form field values

2009-08-20 Thread mkmanning

I'm assuming you want the current value of the checked checboxes. Just
use .serialize()

var inputs = $(input[name^='day']).change(function () {
  console.log(inputs.serialize());
});

the output of serialize() is a query string, just split on '' for an
array of key=value that you can then process further as desired:

var inputs = $(input[name^='day']).change(function () {
  $.each(inputs.serialize().split(''),function(i,d){
   d = d.split('=');
   d[0]; //the key. eg day2
   d[1]; //the value eg mon
  });
});

On Aug 20, 7:34 am, Nathan Bubna nbu...@gmail.com wrote:
 You could use my Values plugin (http://plugins.jquery.com/project/values) and 
 do:

 $(document).ready(function() {
        $(input[name^=day]).change(function () {
             var all = $('input[name^=day]').values();
             for (var day in all) {
                if (all[day] !== null) {
                    alert(all[day]+' was checked');
                }
             }
        });

 });

 rather than just the value of the first matched one, this will give
 you all of their current values in a key-value object.



 On Wed, Aug 19, 2009 at 2:20 PM, blcArmadilloblackarmadi...@gmail.com wrote:

  I have a simple set of checkboxes:

  input name=day1 type=checkbox value=sun / Sun input
  name=day2 type=checkbox value=mon / Mon input name=day3
  type=checkbox value=tue / Tue input name=day4 type=checkbox
  value=wed / Wed input name=day5 type=checkbox value=thu /
  Thu input name=day6 type=checkbox value=fri / Fri input
  name=day7 type=checkbox value=sat / Sat

  When the state of one of them changes I want to check the state of all
  of them. So far I have:
  $(document).ready(function() {
         $(input[name^='day']).change(function () {

         });
  });

  My question is how do I get the value of each of the check boxes? It
  seems like all the commands I see in the jQuery documentation only
  give you the value of the first matched element? Do I have to use some
  sort of for loop? Thanks for the help.


[jQuery] Re: Is this sytax legitimate?

2009-08-19 Thread mkmanning

A couple things that could help in debugging:
ID's are unique, and can't begin with a number. Check the quotes on
this line around #favorites:

var appendHTML = $(‘#favorites’).html();


On Aug 19, 12:48 pm, Rick Faircloth r...@whitestonemedia.com
wrote:
 Hi, Dhruva, and thanks for the reply…

 Yes, there are a lot of variables that could affect the actual data, but I 
 just wanted to make sure, first,

 that it wasn’t a syntax problem.

 Since it’s not, I’ll go a little deeper.

 Basically, I’ve got backend code that generates html and outputs it to a page.

 This is what ends up on the page (userFavoritesHTML.cfm):

 li

      a id=59 class=viewFavoriteDetails link216 West Daryl Drive, 
 Hinesville/a

      span id=59 class=deleteFavorite

           img src=../graphics/delete_over.png style=border:0; 
 cursor:pointer;

      /span

 /li

 li

      a id=60 class=viewFavoriteDetails link51 Julie Lane, Midway/a

      span id=60 class=deleteFavorite

           img src=../graphics/delete_over.png style=border:0; 
 cursor:pointer;

      /span

 /li

 Now I want to append that code to this element:  ul class=”menu1”/ul

 So, I thought I’d do this:

 var favoritesHTML = '../components/userFavoritesHTML.cfm?' + new 
 Date().getTime();

 $('#favorites').load(favoritesHTML);

 var appendHTML = $(‘#favorites’).html();

 $('.menu1').append(appendHTML);

 I need to get the html of #favorites since it’s an li/li in the above 
 ul/ul,

 otherwise, I end up with li’s embedded within other li’s.

 When I run the code above, I get no errors from Firebug, but also no content 
 if

 I use alert(appendHTML), and no content is appended to ul 
 class=”menu1”/ul.

 Thoughts or suggestions?

 Rick

 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On 
 Behalf Of Dhruva Sagar
 Sent: Wednesday, August 19, 2009 1:54 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: Is this sytax legitimate?

 It depends on what $('#favorites').html() contains, have you checked that? 
 Are you sure the id is correct?
 The syntax by itself is absolutely correct, but what you should see in your 
 site is something that depends on a lot of things such as what the  
 $('menu1') contains and what it should etc...try checking if the .html() is 
 returning the right data, then check if it is actually getting appended using 
 firebux, after you have reached that stage and confirmed the same check if 
 the styles are right...

 Thanks  Regards,
 Dhruva Sagar.

 Pablo Picasso 
 http://www.brainyquote.com/quotes/authors/p/pablo_picasso.html   - 
 Computers are useless. They can only give you answers.

 On Wed, Aug 19, 2009 at 11:11 PM, Rick Faircloth r...@whitestonemedia.com 
 wrote:

 $('.menu1').append($('#favorites').html());

 I get no errors in firebug when it’s run, but not code appended to .menu1, 
 either…

 --- 
 ---

 Ninety percent of the politicians give the other ten percent a bad 
 reputation.  - Henry Kissinger


[jQuery] Re: pass different IDs to function?

2009-08-19 Thread mkmanning

Numeric ID's aren't valid, and also an ID can't start with a number.

I'd also recommend removing the inline onclick; you can simplify the
code by just adding a click event on the UL and delegating:

$('#tab_list').click(function(e){
   e = $(e.target), i = $(this).find('li').removeClass
('highlight').index(e);
   e.addClass('highlight');
   $($('.hiding').hide()[i]).show();
});

There are several ways to achieve what you want, HTH.

On Aug 19, 5:35 am, Liam Byrne l...@onsight.ie wrote:
 Did you wrap the tab click function in a document.ready, so that the
 tabs were there to apply the function to ?

 $(document).ready(function() {
     $(.tabs).click( function(){
         var number = $(this).attr(id);
         $(.hiding).hide();
         $(#div+ number).show();
         $(.tabs).removeClass(highlight);
         $(this).addClass(highlight);
     });

 });

 Try an alert in the above to see what it's trying to show.

 I'm also not 100% certain on the advisability of having numeric-only ids ?

 L



 Laura wrote:
  Hi all.    I'm very new at jQuery, and I've gotten myself stuck.    I
  have a set of menu tabs which should show/hide divs on the page, and
  the active tab should change style.  So far I have been able to write
  the following, which does exactly what I want it to:

  function divFlip()
  {
             $(.hiding).hide();
           $(#div1).show();
             $(.tabs).removeClass(highlight);
             $(#1).addClass(highlight);
  }

  which I've called from an onclick in the tab.  (I know that's not
  recommended; I'll get to that.)

  My problem has come in expanding that to affect all the tabs/divs.   I
  can't figure out how to put a variable ID into the thing, so that I
  can have the function work on #div2/#2, #div3/#3, etc.

  I have tried to do a click(function()) that sends (this).attr(id) as a
  variable from the tab clicked on to the function as $(#div +
  variable), thus:

  (.tabs).click( function(){
  var number = $(this).attr(id);
  $(.hiding).hide();
  $(#div+ number).show();
  $(.tabs).removeClass(highlight);
  $(this).addClass(highlight);
  });

  which *DID* work.   However, when I changed over from using the
  onclick to the click(fn), it no longer worked on the first click -- I
  have to double-click on the tabs in order to trigger the show/hide
  behavior.  How can I:

  a) make the click(fn) not need a double-click to work
  or
  b) modify the divFlip function called onclick to work for all tabs/
  divs?

  html below, stripped down to its bare-bones form for testing:
     div id=menu_tabs
             ul id=tab_list
                     li id=1 class=tabs onclick=divFlip1();Div 
  One/li
                     li id=2 class=tabsDiv Two/li
                     li id=3 class=tabsDiv Three/li
             /ul
     /div

  div id=div1 class=hiding
  p This is div 1/p
  /div
  div id=div2 class=hiding
  p This is div 2 /p
  /div
  div id=div3 class=hiding
  p This is div 3 /p
  /div
  

  No virus found in this incoming message.
  Checked by AVG -www.avg.com
  Version: 8.5.409 / Virus Database: 270.13.61/2313 - Release Date: 08/19/09 
  06:03:00


[jQuery] Re: how to get back the DOM element as HTML source

2009-08-18 Thread mkmanning

outerHTML is an IE addition to the DOM and not supported by Firefox.
If you want to get it with jQuery just append the element to a div and
get its html():

$('div').append( $(table:first).clone() ).html()

On Aug 18, 4:37 pm, Jules jwira...@gmail.com wrote:
 Use DHTML property.

 $(table:first)[0].outerHTML

 On Aug 19, 12:36 am, John jian.fang.subscr...@gmail.com wrote:



  Thanks, Anurag. Let me rephrase my question. For example, I can use
  the following jQuery
  to get the html source of a table element

  $(table:first).html()

  The returned html source does not include the table itself, I like to
  see the html source starting
  from the table, for example,

  table class=aaa
  ..
  /table

  Is there any jQuery function for this? If not, how do I implement
  this?

  Thanks in advance,

  John
  On Aug 18, 2:06 am, anurag pal mail.anurag@gmail.com wrote:

   Hi John,

   After setting the html by using html method you have to bind the DOM
   elements using bind method.

   Example:
   script type=text/javascript
       $(.pge).bind(click, function(e){
           var options = {};
             $.ajax({
                       url: data_retrieval.php,
                       cache: false,
                       type: GET,
                         data: ({id : this.getAttribute('id')}),

                       success: function(html){
                           $(#slacker_detail_view).html(html);
                           $('#slacker_detail_view').show('blind', options,
   1500);
                       }
                   });
           });
   /script

   Regards,
   Anurag Pal

   On Tue, Aug 18, 2009 at 7:40 AM, John jian.fang.subscr...@gmail.com 
   wrote:

Hi,

How do I get back the DOM element as HTML source using jQuery? The html
() method only returns the innerHTML and it does not include the UI
element itself. But I am more interested in converting the UI element
itself to HTML.

Thanks in advance,

Jian


[jQuery] Re: Can't get my head around this chain

2009-08-14 Thread mkmanning

@OP: From your example, it appears that the number you want is the
categoryid param in the anchor's href. If that's always the case, you
could save all the DOM traversing and just extract it from the anchor:

$('a:contains(Edit)').click(function(){
  var n = /categoryid=(\d+)/.exec(this.href);
  n = (n  n.length1)?n[1]:n; //null or index 1
  your_function(n);
});

You could make your selector easier if you could add a class to the
anchor, such as $('a.edit'); for that matter you could simplify the
extraction of the ID if you just make it an id on the anchor as well:
a id=c5029 ... (id's can't start with numbers):

this.id.replace('c','');

HTH

On Aug 14, 8:35 am, Laker Netman laker.net...@gmail.com wrote:
 Hi all. Here is a section of a page I generate:
 tr
         tda name=50295029/a/td
         td1100/td
         td2/td
         tda href=index.cfm?
 action=showsubtreeamp;categoryid=5029Products/a/td
         tda href=index.cfm?action=deletenodeamp;categoryid=5029Delete/
 a/td
         tda href=index.cfm?action=newnodeamp;categoryid=5029New/a/
 td
         tda href=index.cfm?
 action=editnodeamp;categoryid=5029amp;categoryName=Productsamp;categoryU 
 RL=amp;categoryType=1amp;parentCategoryId=1100Edit/
 a   /td
         tda href=index.cfm?action=moveupamp;categoryid=5029Move Up/
 a/td
         tda href=index.cfm?action=movedownamp;categoryid=5029Move
 Down/a/td
         tdselect class=mover id=5029
                         option class=selectTitleMove to.../option
                 /select
         /td
 /tr

 When I click on the Edit link in the 7th TD (or 6th for you zero-
 based folks :) I want to call a function and have 5029 available to
 use as a parameter to it. I really don't care which element or
 attribute I use to get the value (as it obviously appears in several
 places), whichever is easiest. I'm thinking the 1st TD, either the a
 name attribute or text.

 I just can't seem to put together a chain of selectors together that
 gets me what I want.

 Can someone help?

 TIA,
 Laker


[jQuery] Re: Forcing JSON parse by headers

2009-08-05 Thread mkmanning

Well, the easy answer is just send JSON in both cases, with the HTML
as part of the JSON response. $.ajax returns the XMLHttpRequest that
it creates, so you could get the content type in your success function
and eval the JSON yourself:

var xhr = $.ajax({ ...
   success: function(data){
console.log( xhr.getAllResponseHeaders() );
console.log( xhr.getResponseHeader('Content-type') );
   }

 });

On Aug 5, 7:53 am, moltar roman.filip...@gmail.com wrote:
 Here is a scenario. I am submitting a form via AJAX. The form may
 either return HTML (when there are input errors) or JSON (successful
 response). If during request I specify dataType: 'json' then HTML
 doesn't get thru correctly, if I don't then JSON is displayed as plain
 text.

 I am sending the application/json header back correctly. I don't
 understand why doesn't jQuery just pick that up and parse it as JSON?
 Is there an option? Is there something I can do to make this work?

 Thank you!


[jQuery] Re: replaceWith()

2009-08-05 Thread mkmanning

The solution doesn't work. $(h2).text() concatenates all the text
from every h2 (it would also miss any markup inside the h2). If you
want to extract the contents into a variable, then you'll have to
iterate over the collection of h2's to do the manipulation.

There are other ways to accomplish this in jQuery. Try this:

$(h2).wrapInner(document.createElement('h3')).find('h3').replaceAll
('h2');


On Aug 5, 8:33 am, Cesar Sanz the.email.tr...@gmail.com wrote:
 @ProfCrazyHorse:
 Your solution seems simple.. why to change something that is working fine?



   - Original Message -
   From: Charlie
   To: jquery-en@googlegroups.com
   Sent: Wednesday, August 05, 2009 6:38 AM
   Subject: [jQuery] Re: replaceWith()

   there are lots of ways in jQuery to create relationships between selectors 
 depending on your markup. Without seeing any markup it's hard for anyone else 
 to help you create those connections

   ProfCrazyHorse wrote:
 I want to replace one element with another, and keep the element
 contents intact.  For example, here, I'm replacing all h2 elements
 with h3's:

 $(a #replaceWith).click(function () {
    var h2Text = $(h2).text();
    $(h2).replaceWith(h3 + h2Text + /h3);
 });

 I have two questions.

 First, how can I do this more simply?  I tried the following, but $
 (this) refers to the anchor tag and not the h2 selector.  Is there a
 way in jQuery to refer to the selector, i.e. $(h2)?

 $(a #replaceWith).click(function () {
    $(h2).replaceWith(h3 + $(this).text + /h3);
 });

 My second question:  Is there a method more appropriate than
 replaceWith to replace certain elements on the apge with others?

 Thank you!


[jQuery] Re: accessing iframe content

2009-07-26 Thread mkmanning

Is your iframe on the same domain? If not, you can't do this.

On Jul 25, 10:39 am, kknaru isai...@gmail.com wrote:
 hi there, i just started working with iframes and i'm stucked :D

 so...i have this code inside a html file:

 iframe id=myframe
          ptext/p
 /iframe

 what i'm trying to do is to grab that paragraph text(using jquery).

 by now i tried something like this:

 $(#myframe).contents().find(p).html();

 butwith no result :(

 does anyone know the answer?


[jQuery] Re: $.browser returning 'wrong' browser version - anyone seen this UA string before?

2009-07-15 Thread mkmanning

You could also just use conditional comments:

!--[if IE 6]
   script src=http://path_to_ie_specific_script.js; type=text/
javascript/script
![endif]--

or set a style within the comments and detect that.

On Jul 15, 8:59 am, w1ntermut3 ben.r.ca...@googlemail.com wrote:
 Thank you :)

 I'm trying to do a browser detection for client reasons :(

 They don't want to spend the money on coding IE6 fixes in, they're
 as... frustrated... with IE6 as we are, and have instructed us that
 any visitor reaching the site through it should be presented with a
 message of love, appreciation and alternative browsers.

 Hence my efforts to knock together a script that would direct any IE6
 users to an alternative landing page.


[jQuery] Re: Add function (transverse)

2009-07-13 Thread mkmanning

Is there another way to accomplish this?

$(.post).hover(function () {
$(this).find('.category,.comments').show();
}, function () {
$(this).find('.category,.comments').hide();
});




On Jul 13, 9:50 am, aakoch outofthem...@gmail.com wrote:
 I find it frustrating that the transversing add function (http://
 docs.jquery.com/Traversing/add) doesn't allow passing in a context
 like the jQuery function (http://docs.jquery.com/Core/
 jQuery#expressioncontext).

 Here's a use case: I want to select two different classes under the
 same element. Today I have to do:
 $(.post).hover(function () {
     $(.category, this).show();
     $(.comments, this).show();}, function () {

     $(.category, this).hide();
     $(.comments, this).hide();

 });

 or:
 $(.post).hover(function () {
     $(.category, this).add($(.comments, this)).show();}, function () {

     $(.category, this).add($(.comments, this)).hide();

 });

 I would rather have:
 $(.post).hover(function () {
     $(.category, this).add(.comments, this).show();}, function () {

     $(.category, this).add(.comments, this).hide();

 });

 Is there another way to accomplish this? (Well, I know this can be
 done with CSS, but this is just an example.)

 If not, can this functionality be added?

 Thanks,
 Adam


[jQuery] Re: Generating path

2009-07-09 Thread mkmanning

ul has a previous sibling (the h1); I suspect there's a head tag
that's the body's previous sibling. In both cases then, prevAll()
would result in a length of 1.
Also I assume you meant the second paragraph, which starts with In
addition to this the earth.

On Jul 9, 12:27 am, Shashank sayhitoshash...@gmail.com wrote:
 Hello,

 I have an HTML page where when user clicks on a paragraph I want to
 find out its path. I have written a jquery script for it:

 jQuery.fn.extend({
     getPath: function( path ) {
         // The first time this function is called, path won't be
 defined.
         if ( typeof path == 'undefined' ) path = '';
         if ( this.is('html') )
             return '/html' + path;
         // Add the element name.
         var cur = this.get(0).nodeName.toLowerCase();
         var index = this.prevAll().length;
         // Recurse up the DOM.
         return this.parent().getPath( '/' + cur + '[' + index + ']' +
 path );
     }

 });

 On an html page like this
 body
         h1 Testing /h1
         ul
             li
             p Except when the winds rise to a high speed, we seem to
 live in a very tranquil world./p
             p In addition to this the earth revolves round the sun
 at a speed of more than a thousand miles a minute./p
             /li
             li
             p Circling round the earth, in the same way as the earth
 circles round the sun, is our moon. /p
             /li
         /ul
 /body

 Clicking on the second paragraph Except when the winds... generates /
 html/body[1]/ul[1]/li[0]/p[1]. I am not getting why body and ul have
 index 1. Please help. Sorry for the long mail.


[jQuery] Re: Remove margin in last li in Unordered List

2009-07-09 Thread mkmanning

I did not know about eq and I don't have all fing day to figure this

http://docs.jquery.com/Core/index
http://docs.jquery.com/Traversing/eq

Most everything you will need is in the docs. It's worth spending some
time studying them.


On Jul 9, 11:52 am, expresso dschin...@gmail.com wrote:
 I did not know about eq and I don't have all fing day to figure this
 out as I am very new to jQuery.  I do my dilligence and read the
 books, try some stuff out and then when I am not sure of another way
 to do this I post.  It's not like I am posting every step of the way
 although it msut appear that to you.  I tried a few things before I
 posted.

 On Jul 9, 7:04 am, Charlie charlie...@gmail.com wrote:



  of course it won't work, is improper use of index(),
  replace index() with eq()
  Suggestion:
  instead of posting each and every thought and failed function you have 
  every 2 minutes, this example could have been created in a very simple test 
  page to get the methods and syntax sorted out. Would have saved us watch 
  the floundering on each and every step of your grief. Other example you 
  tried $(#mycarousel  li[ + i + ]) is syntax problem with several 
  workarounds including :eq()
  Building simple test pages is one of the best ways to learn jquery IMO. 
  Keeping a simple template including link to jquery google source, and a 
  $(document)ready built in you can build a test page in any directory in 
  almost no time and debug in Firebug
  expresso wrote:tried this but doesn't look like you can do this 
  $(#mycarousel  li).index(i).css(margin-right, 0px).css(padding- 
  right, 6px); On Jul 8, 9:48 pm, expressodschin...@gmail.comwrote:Like 
  something like this $(#mycarousel  li[ + i + ]).css(margin-right, 
  0px).css (padding-right, 6px); On Jul 8, 9:46 pm, 
  expressodschin...@gmail.comwrote:Thanks.  I wonder if you can even access 
  an li by index?On Jul 8, 9:35 pm, MorningZmorni...@gmail.comwrote:Why 
  wouldn't you just use:http://docs.jquery.com/Selectors/last$(#mycarousel  
  li:last).css(property, value);On Jul 8, 10:17 pm, 
  expressodschin...@gmail.comwrote:If I have the following:div 
  class=jcarousel-clip jcarousel-clip-horizontal style=width: 459px; 
  height: 220px;     ul id=mycarousel class=jcarousel-list 
  jcarousel-list- horizontal style=height: 220px; width: 918px; left: 
  0px;         li class=jcarousel-item jcarousel-item-horizontal 
  jcarousel- item-1 jcarousel-item-1-horizontal jcarouselindex=1         
  /li         li class=jcarousel-item jcarousel-item-horizontal 
  jcarousel- item-2 jcarousel-item-2-horizontal jcarouselindex=2         
  /li         li class=jcarousel-item jcarousel-item-horizontal 
  jcarousel- item-3 jcarousel-item-3-horizontal jcarouselindex=3         
  /li /ul /divTrying to figure out how I can do a .each on each li 
  and then add an additional style to the last li in the list.


[jQuery] Re: Checking value

2009-07-08 Thread mkmanning

FYI this:

if ('http://example.com/foo/bar.html' === $('a', $(this)).attr
('href')) {
alert('Hooray!');
}

is the same as your original code, except for the full url.


On Jul 8, 3:25 am, brightdad...@googlemail.com
brightdad...@googlemail.com wrote:
 Yes it worked!

 On Jul 8, 10:09 am, brightdad...@googlemail.com



 brightdad...@googlemail.com wrote:
  Hi Experts,

  I am trying to conditionally test what the value of href is equal to.

  like this;

  if($(this).find('a').attr(href)==map.html){
   alert(yes);

  }

  This doesn't work. Do anyone knows what i am doing wrong.

  Psuedocode please.


[jQuery] Re: how to change 2,5 to 2,50 ?

2009-07-07 Thread mkmanning

There are also some currency formatting plugins:

http://plugins.jquery.com/project/currencyFormat

(or search currency under plugins)

On Jul 7, 3:11 am, weidc mueller.juli...@googlemail.com wrote:
 hi,

 thats my code:

 endpreis =Math.round(endpreis*100)/100;

 to round the price of something but i'd like to have 2,00 or 2,50
 instead of 2 and 2,5.

 i'd be happy about any help.

 --weidc


[jQuery] Re: Ajax call modifying returned html

2009-07-07 Thread mkmanning

The effects functions apply a style of display:block, which causes
problems for tables. Try
wrapping the table in a div and apply the effect to the div .

On Jul 7, 5:45 pm, Will D willb...@gmail.com wrote:
 I have a similar issue with hiding / showing table data.

 I have a single table with two tbody elements and I have 2 buttons that
 toggle the display of each tbody using show() + hide(). Whenever I hide the
 first and display the second tbody for some reason the second tbody upon
 display looks like every cell has had additional padding applied to it. I've
 managed to fix it by adding a css style width:1% to some of the td elements.
 That worked for me until I can find out more about it. If you don't
 understand what I mean I can post up an example of the issue I had and what
 I've used to temporarily fix it.

 Is your problem similar to mine?


[jQuery] Re: getJSON callback? does not work with querystring param

2009-07-06 Thread mkmanning

For JSONP, the server needs to wrap the response in the supplied
callback. The cross-domain getJSON function is basically appending a
script to the page, with the contents of that script being a function
containing the data you want to pass back. Play around with the URL in
the flickr example from the docs and you can see how the response is
wrapped:

http://api.flickr.com/services/feeds/photos_public.gne?tags=cattagmode=anyformat=jsonjsoncallback=foo


On Jul 6, 7:44 am, expresso dschin...@gmail.com wrote:
 This works fine:

             $.getJSON(http://localhost:59396/xxxWeb/
 CarouselHandler.ashx?action=getproductsids= + ids,
                 function(data) {

                     carousel.size(allProductIDs.length);

                     if (numberOfImagesLeftToShow 
 numberOfImagesToDisplay) {
                         first += (numberOfImagesToDisplay -
 numberOfImagesLeftToShow);
                     }

                     var d = 0;
                     for (var i = first; i = last; i++) {

                         if (d != undefined) {
                             // add data using index of the array
 returned by JSON (which starts at 0)
                             carousel.add(i, decode(data[d].ImageTag));
                         }

                         // set to last ProductID showing in Carousel
                         if (i == last) { lastProductID = parseFloat
 (data[d].ProductID); }

                         d++;
                     }
                 }
             );

 This does not work, I get no pictures rendered after trying to add the
 format=jsonjsoncallback=? :

             $.getJSON(http://localhost:59396/xxxWeb/
 CarouselHandler.ashx?action=getproductsids= + ids +
 format=jsonjsoncallback=?,
                 function(data) {

                     carousel.size(allProductIDs.length);

                     if (numberOfImagesLeftToShow 
 numberOfImagesToDisplay) {
                         first += (numberOfImagesToDisplay -
 numberOfImagesLeftToShow);
                     }

                     var d = 0;
                     for (var i = first; i = last; i++) {

                         if (d != undefined) {
                             // add data using index of the array
 returned by JSON (which starts at 0)
                             carousel.add(i, decode(data[d].ImageTag));
                         }

                         // set to last ProductID showing in Carousel
                         if (i == last) { lastProductID = parseFloat
 (data[d].ProductID); }

                         d++;
                     }
                 }
             );

 Same for here, calling to our dev server.

 $.getJSON(http://xxxdev/xxx/CarouselHandler.ashx?
 action=getproductsids= + ids + format=jsonjsoncallback=?,
                 function(data) {

 No idea why.  No errors, nothing.


[jQuery] Re: getJSON callback? does not work with querystring param

2009-07-06 Thread mkmanning

You mentioned Access to restricted URI denied, which is a cross-
domain error. Just as an FYI, making a request to a different port
number will trigger this. Something to always keep in mind when
working with ajax.

On Jul 6, 10:09 am, expresso dschin...@gmail.com wrote:
 Ok, so their sending back a json response wrapped with method foo.  So
 then how would you specify foo in my example as the method to call on
 the getJSON script I've created?

 I think my example is fine as it is.  We're not going cross server for
 now but wanted to understand how to form this and how this worked a
 little more.  MK explained the response coming back, a huge part of
 this!  The jQuery docs need to explain this, it's pretty inferred to
 some who have done this before, but not that obvious to others that
 this is how it works...that you are essentially wrapping what you are
 sending back in the method that you want to call in your callback.

 On Jul 6, 10:56 am, Bill Ramirez betbuil...@gmail.com wrote:



  If you pass a param to the json call, it gets passed into the
  querystring:

  $.getJSON(jsdata/customerhandler.ashx, { show: Math.random(),
  departmentId: dptId}, customerLoaded);

  would be rendered as:

  jsdata/customerhandler.ashx?show=0.23231553departmentId=123

  the second parameter to the getJson function is the query string
  parameters.


[jQuery] Re: Function to parse query string from URL?

2009-07-05 Thread mkmanning

http://plugins.jquery.com/project/parseQuery

(minified it's 449 bytes 
http://plugins.jquery.com/files/jquery.parsequery.min_.js_.txt)



On Jul 5, 1:41 pm, candlerb b.cand...@pobox.com wrote:
 Hello, a quick question in case I'm being stupid :-)

 I see that jQuery provides a function to turn an object into a set of
 URL query parameters:

     $.param({foo:xxx, bar:yyy}) = foo=xxxbar=yyy

 My question is: is there a function which does the opposite, i.e.
 parsing a query string into an object?

 The reason is that when I make an Ajax request, I want to take some
 parameters from the original page and include them in the new request,
 and modify others.

 I can get the original page's query string from location.search, which
 may contain, say, ?foo=xxxbar=yyy

 Now, suppose I want to submit an Ajax request with the same value of
 foo as the original page but a different value of bar, what's the
 cleanest way to do that? Remember that the original query string might
 have the two parts the other way round, i.e. ?bar=yyyfoo=xxx

 If I need to write a function to split this myself, I know it's not a
 major undertaking, but I just wanted to see if I've missed something
 in the API.

 Many thanks,

 Brian.


[jQuery] Re: 2 different ways of doing the same thing?

2009-07-04 Thread mkmanning

Yes and no. The first filters out all inputs that are not checkboxes
before returning the jQuery object.
The second returns all inputs, including checkboxes, and then filters
out those that aren't checkboxes.
The difference is that with the latter, you can operate on the
filtered result, for example adding a css style, and then chain .end()
to revert to the original selection of all inputs and work with them.

On Jul 2, 9:11 am, expresso dschin...@gmail.com wrote:
 Would this not be 2 different ways to do the same thing?

 $('input:not(:checkbox));

 vs.

 $('input').not(:checkbox);


[jQuery] Re: 2 different ways of doing the same thing?

2009-07-04 Thread mkmanning

Would this not be 2 different ways to do the same thing?

Yes and no.
The first finds all inputs and excludes checkboxes, returning the
result in the jQuery object.
The second finds all inputs and returns them to the jQuery object,
then excludes those that are checkboxes.

WIth the latter, you can chain .end() and revert to the original
selection of all inputs including checkboxes.



On Jul 2, 9:11 am, expresso dschin...@gmail.com wrote:
 Would this not be 2 different ways to do the same thing?

 $('input:not(:checkbox));

 vs.

 $('input').not(:checkbox);


[jQuery] Re: simple JSON parse problem!!!

2009-07-02 Thread mkmanning

uploadPicture{errors:[This file was already uploaded]}

isn't valid JSON or JSONP

if uploadPicture is a callback function then it needs ( ) :

uploadPicture( {errors:[This file was already uploaded]} );



On Jul 1, 9:25 pm, Ricardo ricardob...@gmail.com wrote:
 No. JSONP provides a way to pass the JSON response directly to a
 callback function without the need for eval(), independent of what
 you're doing with it. It was conceived to allow cross-domain use of
 JSON, 'cause you don't get the response from XHR but from an appended
 script tag. Think of it like this:

 // in your .JS file
 script
 function shake(data){
   alert( data.stuff );};

 /script

 // now you callwww.jsonp.com/get?format=jsoncallback=shake, and you
 get this string back:
 shake({ stuff: [1,2,3] });

 What happens here, is that there is *no* ajax involved. It all happens
 as if you simply put this into your document:

 script type=text/javascript src=http://www.jsonp.com/get?
 format=jsoncallback=shake/script

 The response text is a new script that contains the data in the
 function (which must be defined before that) call.

 Well, this is already far off from your question, it depends on what's
 running server-side etc. Maybe if you could mention which plugin
 you're using or provide a test page this could be solved easily.

 cheers
 -- ricardo
 On Jul 1, 4:12 pm, Rick Faircloth r...@whitestonemedia.com wrote:



  So...am I to understand that jsonp provides a method by which an image can
  be uploaded after submission of a form as part of a callback function?  I've
  done
  some research on jsonp, but still am not clear about it.

  Rick

  On Wed, Jul 1, 2009 at 1:03 PM, Ricardo ricardob...@gmail.com wrote:

   that is called jsonp. You need to define a function named
   uploadPicture that will get called when the response arrives. jQuery
   handles that for you if you use the proper method (assuming the
   callback name can be set in the request):

   $.getJSON('uploadpicture.php?callback=?, {some:'data'}, function(data)
   {
       alert(data.errors[0]);
   });

  http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback

   On Jul 1, 10:16 am, theozmanbo b.k.osbo...@hotmail.com wrote:
Is it because of the uploadPicture part? Why isn't it valid? Sorry for
   all
these stupid questions.
--
View this message in context:
  http://www.nabble.com/simple-JSON-parse-problem%21%21%21-tp24283450s2...
Sent from the jQuery General Discussion mailing list archive at
   Nabble.com.

  --
  --- 
  ---
  Ninety percent of the politicians give the other ten percent a bad
  reputation.  Henry Kissinger


[jQuery] Re: getJSON 2nd param to pass data

2009-06-29 Thread mkmanning

It uses a GET request, so yes, it converts the name:value pairs into a
querystring. Fiddler's fine but you can view the request in Firebug
(which overall has more value for web development).

On Jun 29, 8:00 pm, expresso dschin...@gmail.com wrote:
 http://docs.jquery.com/Ajax/jQuery.getJSON

 I don't get what it means in this example:

 Load the JSON data from test.js, passing along additional data, and
 access a name from the returned JSON data.

 $.getJSON(test.js, { name: John, time: 2pm }, function(json){
   alert(JSON Data:  + json.users[3].name);

 });

 ok, so passes additional data HOW?  querystring I presume?  Not enough
 info and I tried it but I can't tell what's being passed..guess I'll
 fire up Fiddler.


[jQuery] Re: Float Image on Page

2009-06-29 Thread mkmanning

Quick example:

$(document).ready(function(){
var floater = function(){
 $('img').animate( {'marginTop':(Math.random() * $(window).height())
+ 'px','marginLeft':(Math.random() * $(window).width()) + 'px'},
2000,'linear',function(){
setTimeout(floater,10);
 } );
}
floater();
});

Hope that can give you someplace to start.

On Jun 29, 4:32 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 I have been trying to find a solution to this for a while, but all I
 can find is about style:float which is not what I want.

 I would like to animate an image randomly around the screen.  So, it
 could slowly float across the screen, and would randomly choose its
 motion.

 Any ideas?


[jQuery] Re: getJSON parameter - long string

2009-06-26 Thread mkmanning

In a GET request the length of the URL is also browser dependent. IE
has the shortest (at least as of IE7) at 2,083 characters with no more
than 2,048 in the path portion. A non-scientific 2006 test showed
Firefox to accept at least 100,000 characters, Safari at 80,000
characters, Opera at 190,000 characters.

Apache's limit at that time was about 4,000 characters before a 413
Entity too large error. IIS had a default limit of 16,384, but it's
configurable.

Given the amount of text that could be entered into the FCK editor,
POST is really your only option unless you enforce a character limit.

On Jun 26, 3:07 am, saa...@gmail.com saa...@gmail.com wrote:
 Hi

 I am trying to send with getJSON a very long string as parameter:

 $.getJSON(/ajax.php,{id:myid, thetext:mytext},myAjaxResult)
 where mytext - is value from my fckeditor.

 If mytext value is not so long, everything is going fine, but if it
 become a very long, getJSON doesn't work.

 How can I solve this question?


[jQuery] Re: Filtering a select list

2009-06-26 Thread mkmanning

Some quick source code:

HTML:
spanAll/span spanB/span ... spanW/span
select size=6
optionBellucci, Monica/option
optionBernhardt, Daniel/option
optionChou, Collin/option
optionFishburne, Laurence/option
optionGaye, Nona/option
optionHulme, Lachy/option
optionLees, Nathaniel/option
optionLennix, Harry J./option
optionMcColm, Matt/option
optionMoss, Carrie-Anne/option
optionO'Reilly, Genevieve/option
optionPerrineau, Harold Jr./option
optionPinkett Smith, Jada/option
optionRayment, Adrian/option
optionRayment, Neil/option
optionReeves, Keanu/option
optionSpence, Bruce/option
optionWeaving, Hugo/option
optionWilson, Lambert/option
optionWong, Anthony/option
/select

JS:
$(document).ready(function(){
//cache the original select and options
var selList = $('select'), opts = selList.find('option');

//filters by first letter of last name as option text
function filterList(ltr){
selList.empty();
if(ltr==='All'){
selList.append(opts);
return;
}
var re = new RegExp(^+ltr,i), newopts = '';
$.each($.grep(opts,function(o,i){return re.test($(o).text
());}),function(){
selList.append(this);
});
}

$('span').click(function(){
filterList( $(this).text() );
});
});

Maybe that will give you someplace to start.

On Jun 26, 8:29 am, shaded dar...@eztransition.com wrote:
 here is a non jquery solution to what i'm looking for.

 http://www.barelyfitz.com/projects/filterlist/index.php/1

 Does anyone know of jquery plugin to do the same or maybe if its easy,
 some quick source code?

 thanks


[jQuery] Re: Object as Function argument

2009-06-24 Thread mkmanning

If you want a really simple example:

function test(o) {
var defaults = {
test: ''
};
for(var k in o){
defaults[k] = o[k];
}
alert(defaults.test);
}

test({test: 'It works!'});

(nb. also assigns new properties to 'defaults')

On Jun 24, 5:16 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 How does jQuery do it for plugins?  I was wanting to be able to use
 callbacks as well in the object.

 What is happening what a plugin uses: var options = $.extend(defaults,
 options);

 Somehow, that is getting the object to pass through as the function
 params.

 Any help on this?

 On Jun 24, 12:09 am, fredrik carl.fredrik.bonan...@gmail.com wrote:



  Not really sure what you are after. But I think you need to make an
  new instance of test first:

  var test = function (defaults){
      this.defaults = defaults || this.defaults;
      alert(this.defaults.test);

  }

  test.prototype = {
      defaults : { test : 'nothing' }

  };

  new test();
  new test({test: 'hello world'});

  On Jun 24, 8:07 am, Nic Hubbard nnhubb...@gmail.com wrote:

   I have used an object in the past as a function argument, but this was
   for a plugin that I wrote.  Using it in the architecture of a plugin
   it worked.

   BUT, this time, I just want to write a normal function, but still use
   an object to set defaults and pass in changes to those defaults
   through as a param.  Is this possible, or do I have to make this a
   jQuery function like $.myfunction() ?

   I am trying:

   function test(defaults)
   {
           var defaults = {
                   test: ''
           };

   alert(defaults.test);

   }

   test({test: 'It works!'});

   The above does not seem to work, and replace the default with that was
   passed in the function.  What am I doing wrong here?


[jQuery] Re: Accessing window DOM through jQuery Core - can't get it to work

2009-06-24 Thread mkmanning

You're opening a blank window; it has no DOM to manipulate (you'd have
to resort to document.write).

On Jun 23, 4:29 pm, ieatsleepsurf michael.schwart...@gmail.com
wrote:
 Goal: From window A, I want to manipulate the DOM of window B, where
 window B is the result of calling window.open().

 My attempts are shown below, but Window B is never updated.

 winRef = window.open(,Window B);

 Try 1:
 $(winRef).find(body).append(div id=containermr container/div);

 Try 2:
 $(winRef).find(body).html(div id=containermr container/div);

 Try 3:
 $(winRef.document.body).append(div id=containermr container/
 div);

 Try 4:
 $(winRef.document.body).html(div id=containermr container/div);

 The jQuery Core doc (http://docs.jquery.com/Core/jQuery#elements)
 claims that it can wrap a window object.
 Browser is FF2.0

 Any tip is greatly appreciated, even if that's impossible.


[jQuery] Re: li:nth-child(10) toggle

2009-06-20 Thread mkmanning

A minor refactor then:

$('.main ul').each(function(){
var $this = $(this), lis = $this.find('li:gt(9)').hide();
if(lis.length0){
$this.append($('li').text('More').click(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ? 'Less' : 
'More');
}));
}
});

Hide everything at index 10+, then check the length of the jQuery
object from that operation. If it's length is greater than 0, go ahead
and add the 'More' link.

On Jun 20, 10:11 am, bombaru bomb...@gmail.com wrote:
 One question with this approach... how would I implement this only on
 groups that contain more than 10 LI's?  Right now it's getting added
 to every LI group.  Groups with less than 10 LI's are also getting the
 more link appended but there is obviously nothing to toggle.

 Thanks again.  This approach is a lot cleaner that what I had
 concocted and work with jQuery 1.3.2.

 On Jun 19, 9:16 pm, bombaru bomb...@gmail.com wrote:



  Thanks mkmanning!!!  I'll give this a try tomorrow and let you know.
  Looking at it though... I'm pretty confident it will do the trick.
  It's amazing how much more efficiently the original chunk of code can
  be written and it still makes perfect sense (actually it's clearer).

  On Jun 19, 7:36 pm, Karl Swedberg k...@englishrules.com wrote:

   Ah, I see. Helps to be able to see the HTML.

   Let us know if mkmanning's approach doesn't do the trick.

   --Karl

   
   Karl Swedbergwww.englishrules.comwww.learningjquery.com

   On Jun 19, 2009, at 5:56 PM, bombaru wrote:

Thanks Karl... I'm not familiar with slice() but will definitely read
up on it.  The problem I'm having with this approach is that every LI
after the 10th one is being hidden.

Here's an example of what the HTML looks like without any JS applied
to it:

ul id=narrow-search
 li class=main
 Category
   ul
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
     liCategory Name/li
   /ul
 /li
 li class=main
 Brand
   ul
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
   /ul
 /li
 li class=mainetc.../li
/ul

The HTML after your approach looks something like this:

ul id=narrow-search
    li class=main
     Category
     ul
           liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
     /ul
     ul style=display:none;
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
     /ul
     a href=#more/a
 /li
 li class=main
 Brand
 ul/
   ul style=display:none;
           liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
     liBrand Name/li
   /ul
   a href=#more/a
 /li
 li class=mainetc.../li
/ul

Something is getting screwed up.  The first group looks good (but the
toggle does not work).  From then on, the following LI groups are all
hidden and there's a strange ul / tag being inserted into the mix.

Any ideas?

On Jun 19, 5:18 pm, Karl Swedberg k...@englishrules.com wrote:
I'd

[jQuery] Re: Accessing the value

2009-06-20 Thread mkmanning

The default value is 'on'. You need to assign a value to each radio;
also the selector you're using selects all of the radios without
distinguishing between selected or not.

Try this to experiment with:

$(':radio.star').click(function(){
console.log($(this).val());
});

Your html should look like:

 input type=radio name=concept class=star value=1 /
 input type=radio name=concept class=star value=2 /
 input type=radio name=concept class=star value=3 /
 input type=radio name=concept class=star value=4 /
etc.

On Jun 20, 10:16 am, W0utR woutr...@gmail.com wrote:
 Hi, i'm using php to create the stars for rating:
 echo 'p';
    echo strongConcept/strong;
    for($i = 1; $i  6; $i ++) {
    ?
        input type=radio name=concept class=star /
    ?php
    }
 echo '/p';

 But how can i know what rating is selected?

 When i use:
 console.log($('input[name=concept]').val());

 i just get: on


[jQuery] Re: li:nth-child(10) toggle

2009-06-19 Thread mkmanning

Try this:

$('.main ul').each(function(){
var $this = $(this), lis = $this.append($('li').text('More').click
(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ? 'Less' : 'More');
})).find('li:gt(9):not(:last)').hide();
});

Since you have more than one '.main ul' you'll need the .each you had
to keep the li's separate. Using li:gt(9):not(:last) selects  any li's
at index 10 or above (zero indexed) and hides them, excluding the last
li which is the newly added link for more/less.

Since the link doesn't go anywhere, you're not creating a usability
problem by assigning the click event to the li itself (although you
can add an anchor and adjust the script accordingly if desired).

On Jun 19, 2:56 pm, bombaru bomb...@gmail.com wrote:
 Thanks Karl... I'm not familiar with slice() but will definitely read
 up on it.  The problem I'm having with this approach is that every LI
 after the 10th one is being hidden.

 Here's an example of what the HTML looks like without any JS applied
 to it:

 ul id=narrow-search
   li class=main
   Category
     ul
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
       liCategory Name/li
     /ul
   /li
   li class=main
   Brand
     ul
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
     /ul
   /li
   li class=mainetc.../li
 /ul

 The HTML after your approach looks something like this:

 ul id=narrow-search
      li class=main
       Category
       ul
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
       /ul
       ul style=display:none;
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
         liCategory Name/li
       /ul
       a href=#more/a
   /li
   li class=main
   Brand
   ul/
         ul style=display:none;
         liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
       liBrand Name/li
     /ul
     a href=#more/a
   /li
   li class=mainetc.../li
 /ul

 Something is getting screwed up.  The first group looks good (but the
 toggle does not work).  From then on, the following LI groups are all
 hidden and there's a strange ul / tag being inserted into the mix.

 Any ideas?

 On Jun 19, 5:18 pm, Karl Swedberg k...@englishrules.com wrote:



  I'd probably use .slice().

  Something like this should work:

     $(document).ready(function() {
       var $list = $('.main ul'),
           $items = $list.find('li'),
           $moreLink = $('a href=#more/a');

       if ($items.length  10) {
         $moreItems = $('ul/ul').append($items.slice(10)).hide();
         $list.after($moreLink).after($moreItems);
         $moreLink.click(function() {
           $(this).text($(this).text() == 'more' ? 'less' : 'more');
           $moreItems.slideToggle();
           return false;
         });
       }
     });

  --Karl

  
  Karl Swedbergwww.englishrules.comwww.learningjquery.com

  On Jun 19, 2009, at 4:54 PM, bombaru wrote:

   There has got to be a better way to write this?  Basically, I'm
   returning a bunch of list item and after the 10th one, setting the
   rest to display:none and adding a more link.  Clicking on the more
   link removes the display:none and adds a less link at the bottom.

   I think jQuery 1.3.2 is having some trouble with the nth-child
   approach.  Can someone 

[jQuery] Re: li:nth-child(10) toggle

2009-06-19 Thread mkmanning

And you can shorten it slightly:

$('.main ul').each(function(){
var lis = $(this).append($('li').text('More').click(function(){
lis.toggle();
$(this).text($(this).text() === 'More' ? 'Less' : 'More');
})).find('li:gt(9):not(:last)').hide();
});

I had the $this left over from a different approach :P

On Jun 19, 3:59 pm, mkmanning michaell...@gmail.com wrote:
 Try this:

 $('.main ul').each(function(){
         var $this = $(this), lis = $this.append($('li').text('More').click
 (function(){
                 lis.toggle();
                 $(this).text($(this).text() === 'More' ? 'Less' : 'More');
         })).find('li:gt(9):not(:last)').hide();

 });

 Since you have more than one '.main ul' you'll need the .each you had
 to keep the li's separate. Using li:gt(9):not(:last) selects  any li's
 at index 10 or above (zero indexed) and hides them, excluding the last
 li which is the newly added link for more/less.

 Since the link doesn't go anywhere, you're not creating a usability
 problem by assigning the click event to the li itself (although you
 can add an anchor and adjust the script accordingly if desired).

 On Jun 19, 2:56 pm, bombaru bomb...@gmail.com wrote:



  Thanks Karl... I'm not familiar with slice() but will definitely read
  up on it.  The problem I'm having with this approach is that every LI
  after the 10th one is being hidden.

  Here's an example of what the HTML looks like without any JS applied
  to it:

  ul id=narrow-search
    li class=main
    Category
      ul
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
        liCategory Name/li
      /ul
    /li
    li class=main
    Brand
      ul
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
      /ul
    /li
    li class=mainetc.../li
  /ul

  The HTML after your approach looks something like this:

  ul id=narrow-search
       li class=main
        Category
        ul
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
        /ul
        ul style=display:none;
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
          liCategory Name/li
        /ul
        a href=#more/a
    /li
    li class=main
    Brand
    ul/
          ul style=display:none;
          liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
        liBrand Name/li
      /ul
      a href=#more/a
    /li
    li class=mainetc.../li
  /ul

  Something is getting screwed up.  The first group looks good (but the
  toggle does not work).  From then on, the following LI groups are all
  hidden and there's a strange ul / tag being inserted into the mix.

  Any ideas?

  On Jun 19, 5:18 pm, Karl Swedberg k...@englishrules.com wrote:

   I'd probably use .slice().

   Something like this should work:

      $(document).ready(function() {
        var $list = $('.main ul'),
            $items = $list.find('li'),
            $moreLink = $('a href=#more/a');

        if ($items.length  10) {
          $moreItems = $('ul/ul').append($items.slice(10)).hide();
          $list.after($moreLink).after($moreItems);
          $moreLink.click(function() {
            $(this).text($(this).text() == 'more' ? 'less' : 'more

[jQuery] Re: Add Class to all form elements

2009-06-18 Thread mkmanning

The :input selector in ':input,:radio,:checkbox' selects all inputs,
selects, textarea's and buttons, the last two selectors are redundant.
The selector in my last example only selects text inputs, radios and
checkboxes, so it will exclude the submit. Swap it for Gustavo's:

$('form').find(':text,:radio,:checkbox').addClass('class');

Also just an FYI, the above is essentially the same as this:

$(':text,:checkbox,:radio',$('form')).addClass('class');

The former is faster in general.

If you did want to capture all form elements (including textareas,
selects, buttons) but just not the submit, you can do this:

$('form').find(':input:not(:submit)').addClass('class');


On Jun 17, 11:56 pm, Loony2nz loony...@gmail.com wrote:
 The easiest implementation was Gustavo's.

 however, how do i exlcude the submit button?

 I guess i can go back and do a single call to remove the class after
 the fact.

 On Jun 17, 11:47 pm, Loony2nz loony...@gmail.com wrote:



  Hi all,

  Just for clarification, there is only one form on the page at any one
  time.

  Thank you all for you thoughts.  I'm going to try them tonite.

  On Jun 2, 9:40 am, mkmanning michaell...@gmail.com wrote:

   if you have inputs that are not within forms
   That should never happen if you're using valid markup ;)

   Although the OP gave no indication there'd be other forms on the page,
   if you want to target a specific form just use the context:

   $(':text,:checkbox,:radio',$('SPECIFIC_FORM')).addClass
   ('YOUR_CLASSNAME');

   Although it's not clear from the OP's text that he wants the classes
   added for styling, that's a reasonable assumption. You're assigning a
   class whose name is set using the value of i (myflied_+i), so
   given that the OP said there could be anywhere from 5 to 10 to 20 to
   50 fields, it would be extremely difficult to use those classes for
   styling purposes.

   Even if the class is to be used only for targeting the form elements
   later with script, you'd have to use a ^= filter on the class name
   since you could have classnames ranging from myfield_0 to
   myfield_50. In short, there's not much to gain by adding the number
   to the end of the class.

   On Jun 2, 9:07 am, waseem sabjee waseemsab...@gmail.com wrote:

Yes but he only wants to add class to forms. myway is loop through all
forms. or all forms with a specific class. then for each form loop 
through
all inputs. this way is better only if you want certain forms not to 
have
the class name or if you have inputs that are not within forms.

On Tue, Jun 2, 2009 at 3:07 AM, mkmanning michaell...@gmail.com wrote:

 Or you could just do this:

 $(':input,:checkbox,:radio').addClass('YOUR_CLASSNAME');

 On Jun 1, 10:24 am, waseem sabjee waseemsab...@gmail.com wrote:
  script
  $(function() {

  var myforms = $(form);

  myforms.each(function(i) {

  var myform = myforms.eq(i);

  var myfields = $(input, myform);

  myfields.each(function(i) {

  var myfield = myfields.eq(i);

  myfield.addClass(myflied_+i);

  });
  });
  });

  /script

  On Mon, Jun 1, 2009 at 7:19 PM, Loony2nz loony...@gmail.com wrote:

   Hey everyone,

   I need help with a jquery task.

   I have a form that has it's HTML inserted into the database (yeah 
   yeah
   I know..not my idea..I'm new here and just finding this out).

   Anyway, each form field has an embedded class in the HTML.

   The form is dynamically generated.  Can be anywhere from 5 to 10 
   to 20
   to 50 fields.

   How can I loop over each form field and add a new class to the 
   field
   (either input or radio or checkbox)?

   Thoughts?

   Thanks!


[jQuery] Re: what is the correct way to test 'display' value in jQuery?

2009-06-18 Thread mkmanning

If you're testing whether an element's display is either 'none' or
'block|inline|static|etc.' (i.e. not 'none') you can also do this:

$('#subnav-1').is(':visible')

or alternately

$('#subnav-1').is(':hidden')

Either of these returns a boolean.

On Jun 17, 11:20 pm, Jake Barnes lawrence.krub...@gmail.com wrote:
 So can I do this?

 if ($('#subnav-1').css('display') == block) $('#subnav-1').css
 ('background-color', '#f00');

 That is, if this element has display:block then turn the background
 red?

 Just a hypothetical example, of course.

 On Jun 17, 10:55 pm, Ricardo ricardob...@gmail.com wrote:



  $('#subnav-1').toggle();

 http://docs.jquery.com/Effects/toggle

  You can also access the display property with $('#subnav-1').css
  ('display');

  On Jun 17, 10:02 pm, Jake Barnes lawrence.krub...@gmail.com wrote:

   This code works, but it seems inelegant:

   if ($(#subnav-1)[0].style.display == block) $(#subnav-1)
   [0].style.display = none;

   This seems to violate The One True jQuery Way:

   [0]

   I assume I'm not suppose to do that.

   The each() method is more elegant, but it is more verbose:

   $(#subnav-1).each(function() {
       if (this.style.display == block) this.style.display = none;

   }

   Curious if there is another, shorter way to do this?


[jQuery] Re: selector, second to last row of table

2009-06-16 Thread mkmanning

A couple quick examples that might help (there're many more ways):

console.log( $('table tr:last').prev() );

var trow = $('table tr');
console.log( $(trow[trow.length-2]) );
console.log( trow.eq(trow.length-2) );

Modify the selectors as needed for multiple/nested tables.

HTH

On Jun 16, 10:46 am, theprodigy tigerseyet...@gmail.com wrote:
 I've been trying for a while to alter the second to last row of a
 table. I've tried several ways. The number of rows is dynamic so I
 can't hard code a number into nth-child. I used $rowNeeded =
 $thisRow.parents('table:first').children().children().length - 1 to
 get the second to last row, but it doesn't seem like I can pass this
 variable into nth-child either.

 How can I select the second to last row of a table?

 Thanks


[jQuery] Re: Finding items in an UL by their LI's Attributes

2009-06-16 Thread mkmanning

$('ul').find('li[typeref=E][typeid=1]')

NB: an id attribute that starts with a number isn't valid markup.


On Jun 16, 10:05 am, Paul Hutson hutsonphu...@googlemail.com wrote:
 Hello,

 I've been trying to work this out for a bit now but seem to have come
 a bit unstuck.

 I'd like to be able to use .find to search an UL element and find
 out if there are any items with two attributes the same as a search
 choice.

 i.e. : My UL looks like this :

 ul
     li id=1 typeref=E typeid=1Element 1/li
     li id=2 typeref=E typeid=2Element 2/li
 /ul

 I would like to do a search of the above UL and get back the id of the
 first LI element you can see in the list there by doing a search for
 typeref=E  typeid=1.  Is that possible using Jquery?

 Any help would be very very gratefully recieved!

 Regards,
 Paul Hutson


[jQuery] Re: dynamically add link after certain hrefs

2009-06-16 Thread mkmanning

You can simplify your approach; it's not necessary to copy the
properties to the new link as you can just get them at runtime when
the link is clicked (you also don't need to iterate over all the
anchors):

$('a href=/modalwindow.htmlimg src=/images/button.jpg//
a').click(function(){
var props = $(this).prev();
//do your modal stuff here using the above 'props' object
console.log( props.attr('href') + ', ' + props.text() );
return false;
}).insertAfter('a');

This will hit every anchor. If you want to target specific anchors
you'll have to make the selector more specific, e.g.:

.insertAfter('a:contains(Document),a:contains(PDF),a:contains
(WebSite)');

or you could use the href attribute with [href$=.doc], etc.

On Jun 15, 3:59 pm, keith2734 keithkee...@gmail.com wrote:
 I work on a portal website that has approximately 700 pages and
 several thousand links. Some of these links are to various documents
 (.doc, .pdf, .xls). I would like to use Jquery to dynamically find
 these links on a page when the pages load and add another link
 directly after it that can invoke a modal window. When the modal
 window opens I need to hold onto the values of the original link as it
 will be stored in a DB. So I think I will need the second link to
 contain the first links name and URL pattern as some sort of property
 that I can store. I am not sure the best way to accomplish this.

 For example:

 The original links would look like:
 a href=testlink.docDocument/href
 a href=testlink2.pdfPDF/href
 a href=www.something.comWebSite/href

 After the JS dynamically updates the link it would look like:

 a href=testlink.docDocument/hrefa href=/modalwindow.html
 property1=testlink.doc property2=Documentimg src=button.jpg//
 a

 a href=testlink2.pdfPDFNAME/hrefa href=/modalwindow.html
 property1=testlink2.pdf property2=PDFNAMEimg src=button.jpg//
 a

 a href=www.something.comWebSite/href


[jQuery] Re: How to flip the image?

2009-06-11 Thread mkmanning

The only way currently to do this in Javascript is to use canvas.

On Jun 10, 5:27 am, David .Wu chan1...@gmail.com wrote:
 Can I make image vertical or horizontal flip by jQuery?


[jQuery] Re: jquery find out which option is selected

2009-06-11 Thread mkmanning

The @ before name has been deprecated as of jQuery 1.2

A shortcut for getting (or setting) a form value is $(this).val();

You can use .serialize() to get the values of a form in toto, or for
specific form fields:

//to get checked values from both groups (assuming they're in a form)
$(form).serialize()

//specific radio onchange -- logs group1=Butter e.g.
$(':radio').change(function(){
console.log( $(this).serialize() );
});

//specific radio onchange -- simple approach
$(':radio').change(function(){
console.log( this.name );
console.log( this.value )
});

Hope that gives you some direction

On Jun 11, 8:46 am, waseem sabjee waseemsab...@gmail.com wrote:
 THE HTML - A group of radio button

 input type=radio name=group1 value=Milk checked=checked Milkbr
 input type=radio name=group1 value=Butter checked Butterbr
 input type=radio name=group1 value=Cheese Cheese
 hr
 input type=radio name=group2 value=Water Waterbr
 input type=radio name=group2 value=Beer checked=checked Beerbr
 input type=radio name=group2 value=Wine checked Winebr

 THE JQUERY

 scrpt type=text/javascript

 $(function() { // wait for DOM to fully load

 var groupone = $(inp...@name='group1']);
 var grouptwo = $(inp...@name='group2']);

 groupone.change(function() {
  var myvalue = $(this).attr(value);
 alert(myvalue);

 });

 grouptwo.change(function() {
  var myvalue = $(this).attr(value);
 alert(myvalue);

 });
 });

 /script



 On Thu, Jun 11, 2009 at 5:36 PM, jjsanders jigalroe...@gmail.com wrote:

  How can i check in a poll which radio button was selected?


[jQuery] Re: Hide parent where a child contains....

2009-06-11 Thread mkmanning

$(fieldset:has(legend:contains('Promotions'))).hide()

On Jun 11, 10:43 am, Jesse jesseainsk...@gmail.com wrote:
 I'm sure that I'm just missing something simple. Basically, I'm trying
 the hide the fieldset element if it contains legendPromotions/
 legend but I can't get it to work. Here is my latest

 jQuery(fieldset:has('legend':contains:('Promotions'))').hide();

 I've tried several variations of this, including trying to hook onto
 the parent element and such, but I just can't get anything to work.
 I'll supply what my HTML code looks like below. Any help would be
 appreciated.

 h1Categories/h1

 fieldset
     legendCuisines/legend
     input type=checkbox name=OnsaleCouponsCategory[] value=48 /

     input type=checkbox name=OnsaleCouponsCategory[] value=49 /

     input type=checkbox name=OnsaleCouponsCategory[] value=50 /

 /fieldset

 fieldset
     legendAtmosphere/legend
     input type=checkbox name=OnsaleCouponsCategory[] value=62 /

     input type=checkbox name=OnsaleCouponsCategory[] value=63 /

 /fieldset

 fieldset
     legendPromotions/legend
     input type=checkbox name=OnsaleCouponsCategory[] value=91 /

     input type=checkbox name=OnsaleCouponsCategory[] value=92 /

     input type=checkbox name=OnsaleCouponsCategory[] value=93 /

     input type=checkbox name=OnsaleCouponsCategory[] value=94 /

     input type=checkbox name=OnsaleCouponsCategory[] value=95 /

     input type=checkbox name=OnsaleCouponsCategory[] value=96 /

 /fieldset


[jQuery] Re: Open div by URL?

2009-06-10 Thread mkmanning

I think the answers, though informative, have gotten off track. If you
want to open a specific DIV based on the hash in the URL, just use:

var div = window.location.hash;

$(div).show();

You should put the necessary checks to make sure there is in fact a
hash in the url, etc.

On Jun 10, 3:24 am, Bennobo benn...@googlemail.com wrote:
 Can I teach jquery to open a specific div by URL?

 Example:http://www.domain.com/help/faq#107

 The FAQ Entry with ID 107 should open immediatly when I go to this
 URL. (show/hide)

 Have a nice day!
 Bennobo


[jQuery] Re: Find text (nodes) within an element?

2009-06-10 Thread mkmanning

Here's a couple other ways:

/F$/.test($('label').text());

or

$('label').text().substr(-1) === F;



On Jun 10, 3:24 pm, ldexterldesign m...@ldexterldesign.co.uk wrote:
 Easy guys,

 labelA B C D E F/label

 Anyone got any tips on how to find out if the last letter of my label
 is 'F'?

 Cheers,
 L


[jQuery] Re: Remove links but not images

2009-06-09 Thread mkmanning

For the example markup you give it's very simple, just do this:

$('ul li a').each(function(){
$(this).replaceWith( $(this).children() );
});


On Jun 9, 6:26 am, Adardesign adardes...@gmail.com wrote:
 Run a .each() to retrieve the images, and delete .remove()
  the images and place them into a var.

 Then remove all li gt(0)  greater then and replace them into one li

 It should be doable...

 On Jun 9, 9:07 am, Armand Datema nok...@gmail.com wrote:

  mm i dont know if this is the best way but you could try

  $(ul a#click).onclick = function() { return false; }

  and then on that link you set a style class with the standard cursor

  Its  a workaround but it works

  On Tue, Jun 9, 2009 at 2:13 PM, alex alex_bille...@hotmail.com wrote:

   Hi folks

   This has me stumped. I have a list of images and I want to remove the
   links but retain the images.

   So this

   ul
   lia href=fooimg src=path/to/image1 //a/li
   lia href=fooimg src=path/to/image2 //a/li
   etc etc
   /ul

   Becomes this

   ul
   liimg src=path/to/image1 //li
   liimg src=path/to/image2 //li
   /ul

   Using this

   $('ul a').remove();

   does not work as it also removes the images as well.

   Any help would be much appreciated. Thanks in advance.

   Alex

  --
  Armand Datema
  CTO SchwingSoft


[jQuery] Re: selector question

2009-06-09 Thread mkmanning

$(div:not(#+pid+) form span).css(background-color,yellow);

On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote:
 Hi,

 Im trying to select all spans in divs containing forms that dont have
 a certain id

 $(div:not([id='#'+pid]) form span).css(background-color,
 yellow);

 This selects all spans regardless of the ID.. Any suggestions
 would be great!

 Thanks in advance...


[jQuery] Re: selector question

2009-06-09 Thread mkmanning

Yes you do, if you want to filter by ID. Unless the variable pid =
#some_id.

On Jun 9, 1:29 pm, Danny d.wac...@prodigy.net wrote:
 You probably don't want the '#' character in there:
 $(div:not(+pid+) form span).css(background-color,yellow);

 On Jun 9, 11:45 am, mkmanning michaell...@gmail.com wrote:



  $(div:not(#+pid+) form span).css(background-color,yellow);

  On Jun 9, 8:19 am, squalli2008 m...@paskell.co.uk wrote:

   Hi,

   Im trying to select all spans in divs containing forms that dont have
   a certain id

   $(div:not([id='#'+pid]) form span).css(background-color,
   yellow);

   This selects all spans regardless of the ID.. Any suggestions
   would be great!

   Thanks in advance...


[jQuery] Re: animate callback scope for infinite loop?

2009-06-08 Thread mkmanning

The above post fails due to this:

obj.animate({ opacity:myOpacity}, 500);
animation();

The animation() function will be called immediately each time. It
should be in obj.animate's callback function. That being said, the OP
was asking how to do this without resorting to setTimeout().

To do that, in your Animation function just set a var to 'this':

 var Animation = function(elementID){
var _this = this;
this.opa = 1;
this.floatAround = function(){
...

then refer to it in your callback:

if(startStop == 1){
  _this.floatAround(); //won't work, because this no longer
points
to the Animation object, but this is what I want to do.
}


On Jun 7, 10:02 pm, waseem sabjee waseemsab...@gmail.com wrote:
 var obj = $(div):
 // i want my objects opacity to go to 1 to 0.6 then follow that pattern

 var animeframe = 0;
 var myOpacity;

 function animation() {
 setTimeout(function() {
 if(animeframe == 0) {
 myOpacity = 0.6;
 animeframe = 1;} else if(animeframe  == 1) {

 myOpacity = 1;
 animeframe  = 0;}

 obj.animate({ opacity:myOpacity}, 500);
 animation();

 }, 1000);
 }

 The Above  animation function has some code wrapped in a setTimeout
 recalling the function after x seconds
 I then access my variable to define to which frame the animation should be
 on and what the properties are to set for that frame.
 i then do the animation and recall the function
 This will loop endlessly between frame one and two as the end can never me
 achieved.

 On Mon, Jun 8, 2009 at 3:11 AM, Bill bill.fisher.oakl...@gmail.com wrote:

  I think you may have misunderstood what I am trying to do.  I need to
  refer to the instance of the Animation object.  Within the callback,
  this already refers to the HTML Element.

  On Jun 7, 4:40 pm, Gustavo Salomé gustavon...@gmail.com wrote:
   try
   $this=$(elementID);

   2009/6/7 Bill bill.fisher.oakl...@gmail.com

Hi,

I'm trying to create an endless animation similar to a screen saver,
where an image floats around the screen, fading in and out.  I would
like to stay out of the global namespace, so I'd like to use the
callback to animate() rather than getTimeout(), which seems to operate
only on functions in the global namespace.  Please correct me if I'm
wrong about that.

But I'm having trouble maintaining the scope I want for the callback
-- I want this to refer to my Animation object, not the HTML
element.  I understand many folks have solved this problem for events
by using bind() or live(), but I am wondering how to do this for
animate().

Here is my code:

$(document).ready(function(){

       var startStop = 1;

       //object for creating animated elements that fade in or out
  while
moving to a random point.
       var Animation = function(elementID){
               this.opa = 1;
               this.floatAround = function(){
                   var top = Math.random() * $('#content').height();
                   var left = Math.random() * $('#content').width();
                       $(elementID).animate(
                                       {       opacity:(this.opa),
                                               marginTop:top+'px',
                                               marginLeft:left+'px'
                                       },
                                       1000,
                                       'linear',
                                       this.callback
                       );
                       this.opa = this.opa  0 ? 0 : 1;
               };
               this.callback = function(){
                       //alert(this); //HTML Image Element -- not what
  I
want.
                       if(startStop == 1){
                               //this.floatAround(); //won't work,
  because
this no longer points
to the Animation object, but this is what I want to do.
                       }
               };
       };

       //user may click on the containing div to stop the animation.
       $('#content').toggle(
               function(){
                       startStop = 0;
               },
               function(){
                       startStop = 1;
                       //floater.floatAround(); //...and maybe start it
again.
               }
       );

       //start the animation
       var floater = new Animation('#animate_me');
       floater.floatAround();
});

thanks for any help in advance!

   --
   Gustavo Salome Silva


[jQuery] Re: who cann't i make it work?my first jquery aspx page

2009-06-07 Thread mkmanning

should be in the head area of the document.
No it shouldn't. You can put it in the head if you like, but
Javascript blocks downloads, it's ideally a behavior layer that
enhances presentation, etc. Much has been written about putting js at
the close of the body as a best practice:
http://developer.yahoo.com/performance/rules.html#js_bottom

Whether at the top or bottom, your script will fail if you don't
include it in the correct order. room.js requires jQuery, but is being
requested before the jQuery library.

On Jun 7, 7:08 am, jerome m...@amosdesigns.net wrote:
   script src=js/room.js type=text/javascript/script
     script src=js/jquery-1.3.2.min.js type=text/javascript/
 script
 should be in the head area of the document.

 - Original Message -
 From: dotnet caiyu...@gmail.com
 To: jQuery (English) jquery-en@googlegroups.com
 Sent: Saturday, June 06, 2009 1:19 PM
 Subject: [jQuery] who cann't i make it work?my first jquery aspx page

  %@ Page Language=C# AutoEventWireup=true CodeFile=Chat.aspx.cs
  Inherits=Chat %
  %@ Import Namespace=OLChatRoom %

  !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://
 www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
  html xmlns=http://www.w3.org/1999/xhtml;
  head runat=server
     title. . . ./title
     link href=~/stylesheet/chatroom.css type=text/css
  rel=stylesheet /
   my .aspx page:
  /head
  body
     form id=form1 runat=server
         input id=hiddenID  type=hidden name=hiddenID
  runat=server/
         asp:ScriptManager ID=ScriptManager1 runat=server
  EnablePartialRendering=True EnablePageMethods=True

         /asp:ScriptManager
  div id=statusullithe person u r chatting to is from
  asp:Label ID=country runat=server Text=an unknown place/
  asp:Label/lili id=tyingStatus/li/ul/div
  div id=txtP/P/div
  div id=Operation
  p id=contentereatextarea id=txtMsg  cols=91 rows=5/
  textarea/p
  div id=clickereadivinput id=btn    type=button value=S E
  N D//divdivinput id=stp type=button value=Stopit //
  div/div/div
     /form
      script src=js/room.js type=text/javascript/script
     script src=js/jquery-1.3.2.min.js type=text/javascript/
  script
  /body
  /html

  my room.js:
  $(document).ready(function(){alert(myfirstjquery);})

  but when i run the .aspx with IE, alert window of  alert
  (myfirstjquery)  doesn't show up.but when i wrap $(document).ready
  (function(){alert(myfirstjquery);}) in a function and invoke it in
  the event onload() of the body ,it works fine.
  i was told $(document).ready() is the execute after the page loaded .


[jQuery] Re: ajax.request equivalent in jquery

2009-06-06 Thread mkmanning

You already set the postBody in your first jQuery conversion: data

The docs should provide you with all the explanations you need.

On Jun 5, 12:31 pm, deex deecodame...@gmail.com wrote:
 Hey all...

 I am doing a conversion of prototype to jquery and am stuck on a
 script... I can't figure out how to define certain fields.

 Here's the prototype call:

 new Ajax.Request(url,
           {
             method:'post',
                         postBody: 'media_id='+media_id,
             onSuccess: trigger,
                         onComplete: function()
                                 {
                                 leftPos = 
 Position.positionedOffset($('doc'))[0];

                                 if (window.pageYOffset)
                                 ScrollTop = window.pageYOffset;

                                 else
                                 ScrollTop = (document.body.parentElement) ?
 document.body.parentElement.scrollTop : 0;

                                 $('fade').setStyle({height: 
 $('doc').getHeight()+'px'});
                                 $('popup').setStyle({left: 
 (leftPos+138)+'px'});
                                 $('popup').setStyle({top: 
 (ScrollTop+50)+'px'});
                                 }
           });

 I've attempted to convert and got this far...

 jQuery.ajax({type: POST,
                     url: url,
                     data: 'media_id='+media_id,
                     success: trigger,
                     complete: function() {

                      leftPos = Position.positionedOffset(jQuery('#doc'))
 [0];

                      if (window.pageYOffset)
                                 ScrollTop = window.pageYOffset;

                      else
                                 ScrollTop = (document.body.parentElement) ?
 document.body.parentElement.scrollTop : 0;

                                 jQuery('#fade').setStyle({height: 
 jQuery('#doc').height
 ()+'px'});
                                 jQuery('#popup').setStyle({left: 
 (leftPos+138)+'px'});
                                 jQuery('#popup').setStyle({top: 
 (ScrollTop+50)+'px'});}
                     });

 To make things worse, there's a check in there to see if you're logged
 in and if not calls the following:

 new Ajax.Request('/profile/signin?noredirect=1',
           {
             method:'post',
             postBody: Form.serialize($('signin_form_popup')),
             onSuccess: callback
           });

 which I've attempted to convert to :

 jQuery.ajax({type:'POST',
                     url: '/profile/signin?noredirect=1',
                     postBody: Form.serialize(jQuery
 ('#signin_form_popup')),
                     success: callback});

 I think it's all working but am not sure...I have no idea what to do
 with the postBody parameter...what is it's equivalent in jquery.

 Any help would be greatly appreciated.

 Thanks


[jQuery] Re: urgent json parsing error!!!! very important

2009-06-06 Thread mkmanning

It's not a cross-domain security issue, it's a JSONP issue (maybe an
authentication issue). Twitter's API allows you to make GET requests
which are returned as JSON with an option to specify a callback
function. Afaik it doesn't support JSONP however. You can add
callback=some_function and the response will be:

some_function(true)

In a cross-domain getJSON call jQuery appends the response to the
document in a SCRIPT tag (no ajax involved). The problem may be that
this is an API call that requires authentication. I say 'may' because
it looks like you can hit the URL in the browser (try Chrome) and get
the response back without setting the auth header. (try
http://twitter.com/friendships/exists.json?user_a=cnnuser_b=cnnicallback=foobar)

My first suggestion is create a global callback function, then append
that function name to the URL (as above).


On Jun 6, 1:39 pm, Aaron Gundel aaron.gun...@gmail.com wrote:
 My guess is that you're not building an extension for twitter that
 will run on their site, so you're violating the cross domain request
 rule.  You cannot directly request from twitter.com, you'd have to
 proxy through a page on your site (some page that forwarded this
 request to twitter and returned the same result) or you can use jsonp
 to achieve the same effect, which is probably what you're looking for.
  Hopefully this will help you.

 $(document).ready(function(){
                        $.ajax( {
                                            url: 
 'http://twitter.com/friendships/exists.json?user_a='+
 usera + 'user_b=' + userb,
                                            dataType: jsonp,
                        success: function(data)
                        {
                                                         if(data == true)
                                                         {
                                                                 var newDiv = 
 'ptrue/p';
                                                         }

                                                         
 $('#content').append(newDiv);
                        }
                        })});

 On Sat, Jun 6, 2009 at 3:47 AM, grand_unifierjijodasgu...@gmail.com wrote:

  !-- this is the javascript json parser function --

     script type=text/javascript src=../jquery-1.2.6.min.js
     /script

     script type=text/javascript

     $(document).ready(function()
      {
                 $('form#search').bind(submit, function(e)
                 {
                         e.preventDefault();
                         $('#content').html('');

                         var query1 = urlencode($('input[name=user_a]').val
  ()); //userA
                         var query2 = urlencode($('input
  [name=user_b]').val()); //userB

                         
  $.getJSON('http://twitter.com/friendships/exists.json?
  user_a='+query1+'user_b='+query2,
                         function(data)
                         {

                                   if(data.text == 'true')
                                     {
                                       var newDiv = 'ptrue/p';
                                     }

                              $('#content').append(newDiv);

                                 });
                         });
                 });

           function urlencode(str) {
             return escape(str).replace(/\+/g,'%2B').replace(/%20/g,
  '+').replace(/\*/g, '%2A').replace(/\//g, '%2F').replace(/@/g, '%40');
           }
     });

     /script

  !-- javascript ends here --

  i dont understand wats wron wth this code...could anyone plz correct
  itplzits very frustratin...
  any help wil be appreciated...


[jQuery] Re: Moving a div container from within to before a p container

2009-06-06 Thread mkmanning

Waseem's answer doesn't look good for a couple reasons, most
importantly calling obj.remove(). That will delete the image from the
DOM, which renders every action before it pretty useless :P

It also doesn't take into account the OP's request to also include the
caption text if it exists.

Try this to get familiar with chaining and manipulation:
$('p').wrapInner('div/div').children().insertBefore($('p'));

If you're working from having a reference to the image (where this ==
your image):
var p = $(this).parent();
p.wrapInner('div/div').children().insertBefore(p);

HTH

On Jun 6, 3:48 pm, infoaddicted jack.lapla...@gmail.com wrote:
 wasseem's answer looks good, I'd just like to off a little friendly
 advice on coding style, advice meant to make revisiting
 your own code in the future easier as well as making it under-
 standable to others.

 in a block like:

     {
         var a= $(this).attr('alt');
         ...
     }

 consider using more user friendly variables names, like

     var alt = ...
     var substr_1 = ...

 and putting spaces around operators like the concatenation

     foo + bar

 the few bytes added to your code size is a very small percentage
 of your total page size.

 You can find a lot of good advice in the same vein here:

 Code Conventions for the JavaScript Programming Language
  -http://javascript.crockford.com/code.html

 On Jun 6, 5:11 pm, Bruce MacKay b.mac...@massey.ac.nz wrote:

  Hi folks,

  The following function takes an image tag (or table) that appears
  within a p tag container in the form
   p img text  /p

  and wraps the image (and caption if a title is present) into a div
  for floating left, right, or centering.

  My problem is that I don't know how to shift the processed image from
  within the p container to immediately before it (so that the created
  div is not within a p container)

  I'd appreciate help in this next step.

  Thanks,

  Bruce

  function fnDoImages() {
           
  $('img.imgposl,img.imgposr,img.imgposc,img.tblposl,img.tblposr,img.tblposc' 
  ).each(function(i)
  {
                   var a = $(this).attr('alt');
                   var q = $(this).attr('class').substr(0,3);
                   var p = $(this).attr('class').substr(6);
                   var t = $(this).attr('title');
                   var w = $(this).attr('width');
                   if (a.length=0) {
                           $(this).attr('alt',''+t+'');
                   }
                   $(this).wrap(div class='buggybox clearfix'
  id='g+i+'/div);
                   if (q=='tbl'  t.length0) {
                   $(this).before(p class='imgcaption'
  style='width:+w+px;'+t+/p);
                   } else if (t.length0){
                   //$(this).after(p class='imgcaption'
  style='width:+w+px;'+t+/p);
                   };
                   $(#g+i).addClass(img+p).css({width:w+'px'});
           });

  }


[jQuery] Re: Moving a div container from within to before a p container

2009-06-06 Thread mkmanning

This still won't move the optional caption text (see my post above).

On Jun 6, 4:21 pm, Charlie charlie...@gmail.com wrote:
 One reason I follow this board is to learn how to do things I haven't 
 encountered. I had no idea off top of my head how to do what you want but in 
 quest to learn jQuery many of the problems on this board are great for 
 training one's self. Thanks to team jQuery for such a good library and for 
 excellent API docs and examples
 solution is very straight forward and easy to test with the markup of p 
 some text img //p
 //test example
 $(img).each(function() {
        if ($(this).parent().is(p)){   
                    alert(My Parent is a P);
                $(this).insertBefore($(this).parent());                   
         }
      });
 in your case you should be able to put following right after your 
 .each(function (i) {:
 if ($(this).parent().is(p)){               
                $(this).insertBefore($(this).parent());                   
         }
 ///rest of your function
 var a = $(this).attr('alt');
 Bruce MacKay wrote:Hi folks,
 The following function takes an image tag (or table) that appears within a p 
 tag container in the form p img text  /pand wraps the image (and 
 caption if a title is present) into a div for floating left, right, or 
 centering.
 My problem is that I don't know how to shift the processed image from within 
 the p container to immediately before it (so that the created div is not 
 within a p container)
 I'd appreciate help in this next step.
 Thanks,
 Brucefunction fnDoImages() {
  
 $('img.imgposl,img.imgposr,img.imgposc,img.tblposl,img.tblposr,img.tblposc').each(function(i)
  {
  var a = $(this).attr('alt');
  var q = $(this).attr('class').substr(0,3);
  var p = $(this).attr('class').substr(6);
  var t = $(this).attr('title');   
  var w = $(this).attr('width');
  if (a.length=0) {
    $(this).attr('alt',''+t+'');
  }
   $(this).wrap(div class='buggybox clearfix' 
 id='g+i+'/div);
  if (q=='tbl'  t.length0) {
   $(this).before(p class='imgcaption' 
 style='width:+w+px;'+t+/p);
  } else if (t.length0){
   //$(this).after(p class='imgcaption' 
 style='width:+w+px;'+t+/p);
  };
   $(#g+i).addClass(img+p).css({width:w+'px'});
 }); 
 }


[jQuery] Re: re-establish user selection in a div with designmode=true

2009-06-05 Thread mkmanning

For FF:
window.getSelection().removeAllRanges();
range = document.createRange()
range.setStart(YOUR_ELEMENT, start_position);
range.setEnd(YOUR_ELEMENT, end_position); //0
window.getSelection().addRange(range);

For IE the equivalent is something like:
get the range with document.body.createTextRange()
call moveToElementText, call setEndPoint, call moveStart, call
moveEnd, then select().

It's been a while since I've had to work with any of this (and
fortunately I wasn't having to code for IE at the time).

Getting your start position is part of the problem if the caret was in
a bunch of nested elements. One thing that might help is to pass
window.getSelection() to the Firebug console and then you can expand
the object to see all of the available methods (which won't
necessarily be the same in IE :( ).

I'm afraid jQuery won't be of help here. A good source for information
on the Range and Selection objects is MDC: 
https://developer.mozilla.org/En/DOM:Range

Unfortunately, cross-browser implementations of the Range object are
inconsistent and the documentation minimal.

HTH :)

On Jun 5, 1:34 pm, dhoover dh.ferm...@gmail.com wrote:
 I have a web app where I have created a div to masquerade at a
 textarea so I can add highlighting according to so rules. I rely on
 setting designmode=true. After certain amounts of idle time my code
 grabs the text from the div, which consists of p tags and span
 tags and re-generates the html with new spans. The paragraphs and text
 stay the same. So far so good. But when the div repaints the
 insertion is set to the beginning of the div. I want it to visually
 stay put, meaning I need to somehow record where it was before and
 then restore it afterwards.

 Problem is, I can't seem to get my head wrapped around how selections
 (Ranges, etc.) work. I've been googling around for the last day or so
 and have not yet seen the light.

 Any ideas?


[jQuery] Re: text of first sibling of a parent...How do I get it

2009-06-03 Thread mkmanning

The problem with parents() in the example given is that if your page
structure is more complex, and has nested tables for example, then
parents() will return all parent tables. Likewise if there are tr's
preceding the tr in your example. Here's a couple ways to get the text
you're asking for:

$('#knowndiv').closest('tr').find('td:first').text();

$('#knowndiv').parent().prevAll(':last').text();

HTH :)

On Jun 3, 6:33 am, jake dimano jakedim...@gmail.com wrote:
 Mauricio, your code basically works fine on a simple test page.  But
 there is something about my set-up that makes the bit about
 .parents('table') fail.  My page still has the same exact element
 structure with 2 differences; there are 52 trs in the table; also,
 all the elements (tables, trs, tds, divs...what have you,) are all
 full of styles, attributes, and onclick events to a fairly large
 extent.

 Other variations and combination of jQuery functions fail as well in
 getting the parent of this div in my page.

 I guess I'll just keep on truckin'.
 jake

 On Tue, Jun 2, 2009 at 3:52 PM, Mauricio (Maujor) Samy Silva

 css.mau...@gmail.com wrote:
  var myText = $('#knowndiv').parents('table').find('td:first').text();
  alert(myText);

  Maurício

  -Mensagem Original-
  De: con-man-jake
  Para: jQuery (English)
  Enviada em: terça-feira, 2 de junho de 2009 16:38
  Assunto: [jQuery] text of first sibling of a parent...How do I get it

  Still a newbie.
  I have this:

  table
     tr

    td
   text I want to get
    /td

    td
    /td

    td
   div id=knowndiv/div
    /td

     tr
  /table

  If I have the div with id of knowndiv as an object (call it obj),
  How do I get the text inside the first td?


[jQuery] Re: Add Class to all form elements

2009-06-02 Thread mkmanning

if you have inputs that are not within forms
That should never happen if you're using valid markup ;)

Although the OP gave no indication there'd be other forms on the page,
if you want to target a specific form just use the context:

$(':text,:checkbox,:radio',$('SPECIFIC_FORM')).addClass
('YOUR_CLASSNAME');

Although it's not clear from the OP's text that he wants the classes
added for styling, that's a reasonable assumption. You're assigning a
class whose name is set using the value of i (myflied_+i), so
given that the OP said there could be anywhere from 5 to 10 to 20 to
50 fields, it would be extremely difficult to use those classes for
styling purposes.

Even if the class is to be used only for targeting the form elements
later with script, you'd have to use a ^= filter on the class name
since you could have classnames ranging from myfield_0 to
myfield_50. In short, there's not much to gain by adding the number
to the end of the class.


On Jun 2, 9:07 am, waseem sabjee waseemsab...@gmail.com wrote:
 Yes but he only wants to add class to forms. myway is loop through all
 forms. or all forms with a specific class. then for each form loop through
 all inputs. this way is better only if you want certain forms not to have
 the class name or if you have inputs that are not within forms.

 On Tue, Jun 2, 2009 at 3:07 AM, mkmanning michaell...@gmail.com wrote:

  Or you could just do this:

  $(':input,:checkbox,:radio').addClass('YOUR_CLASSNAME');

  On Jun 1, 10:24 am, waseem sabjee waseemsab...@gmail.com wrote:
   script
   $(function() {

   var myforms = $(form);

   myforms.each(function(i) {

   var myform = myforms.eq(i);

   var myfields = $(input, myform);

   myfields.each(function(i) {

   var myfield = myfields.eq(i);

   myfield.addClass(myflied_+i);

   });
   });
   });

   /script

   On Mon, Jun 1, 2009 at 7:19 PM, Loony2nz loony...@gmail.com wrote:

Hey everyone,

I need help with a jquery task.

I have a form that has it's HTML inserted into the database (yeah yeah
I know..not my idea..I'm new here and just finding this out).

Anyway, each form field has an embedded class in the HTML.

The form is dynamically generated.  Can be anywhere from 5 to 10 to 20
to 50 fields.

How can I loop over each form field and add a new class to the field
(either input or radio or checkbox)?

Thoughts?

Thanks!


[jQuery] Re: CSS attributes as a variable.

2009-06-02 Thread mkmanning

$(h1).css({'color':color});

On Jun 2, 11:50 am, jeff jeffreykarbow...@gmail.com wrote:
 Hello, I am trying to get the color of an element and change the color
 of another element with that color. Does this make sense?

 What is wrong with this? I would like all of the H1 tags to inherent
 the color of .ui-state-error. Thank you in advance!

 $(function(){
                    var color = $('.ui-state-error').css('color');
                    $(H1).css({'color', ' + color + '});
                    });


[jQuery] Re: How to prevent a particular field being submitted in form submission

2009-06-02 Thread mkmanning

To set the value of a form field, use this:

$(#myFieldId).val()

To do this without setting the field to an empty value, modify your
original approach:

$(#MyForm).submit(function(){
var params = $(this).serializeArray();
$.post('/register.php',
$(params).filter(function(){
return this.name != data[User][passwd];
}),
callback,
json
);
return false;
});

On Jun 2, 7:17 pm, Clare little.miss.miracle.g...@gmail.com wrote:
 I tried disabing the field, but unfortunately no respose from the
 server in ajax call.
 $(#myFieldId).attr({value:}) works fine.
 Is there any way to do this without resetting the field value?


[jQuery] Re: Add Class to all form elements

2009-06-01 Thread mkmanning

Or you could just do this:

$(':input,:checkbox,:radio').addClass('YOUR_CLASSNAME');


On Jun 1, 10:24 am, waseem sabjee waseemsab...@gmail.com wrote:
 script
 $(function() {

 var myforms = $(form);

 myforms.each(function(i) {

 var myform = myforms.eq(i);

 var myfields = $(input, myform);

 myfields.each(function(i) {

 var myfield = myfields.eq(i);

 myfield.addClass(myflied_+i);

 });
 });
 });

 /script

 On Mon, Jun 1, 2009 at 7:19 PM, Loony2nz loony...@gmail.com wrote:

  Hey everyone,

  I need help with a jquery task.

  I have a form that has it's HTML inserted into the database (yeah yeah
  I know..not my idea..I'm new here and just finding this out).

  Anyway, each form field has an embedded class in the HTML.

  The form is dynamically generated.  Can be anywhere from 5 to 10 to 20
  to 50 fields.

  How can I loop over each form field and add a new class to the field
  (either input or radio or checkbox)?

  Thoughts?

  Thanks!


[jQuery] Re: Apply or remove style - Not workingin IE versions

2009-05-25 Thread mkmanning

If you're html is as you say, you're closing a dl with a div:
dl class=entryphp rendered content /div

As an aside, why not just chain the js?
$('#resume_education dl:first').removeClass('entry').addClass
('first_entry');

On May 24, 7:09 pm, Dave Maharaj :: WidePixels.com
d...@widepixels.com wrote:
 What I have below  works only in FF.
 In my html i have dl class=entryphp rendered content /div

 css:
 .resume dl.first_entry {padding:10px 0 10px 25px; float:left; border:none}
 .resume dl.entry{padding:10px 0 10px 25px; float:left; border-top:1px dotted
 #CCC}

 js;
 $('#resume_education dl:first').removeClass('entry');
 $('#resume_education dl:first').addClass('first_entry');

   _  

 From: Mauricio (Maujor) Samy Silva [mailto:css.mau...@gmail.com]
 Sent: May-24-09 8:14 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: Apply or remove style - Not workingin IE versions

 Would you please provide a sample for your HTML markup?
 Maurício

 -Mensagem Original-
 De: Dave Maharaj ::  mailto:d...@widepixels.com WidePixels.com

 Not working in IE at all. Works in FF but noting in IE 5.5 to 7
 $('#resume_education dl:first').addClass('first_entry');


[jQuery] Re: When is jQuery available?

2009-05-23 Thread mkmanning

We've been using jQuery served by Google for almost a year, on a site
that gets about 5 million pageviews a month, with no problems. Is your
page using https by any chance?

On May 22, 3:58 pm, intrader intra...@aol.com wrote:
 I am having a problem when loading jSquey from the Google CDN as
 follows:        script src=http://ajax.googleapis.com/ajax/libs/jquery/
 1.3.2/jquery.min.js/script!-- does not work --.
 I have verified that the URL is correct and ir used in IE, the library
 is downloaded.
 I have used in in a site that does not require proxy, and it works
 fine.
 Otherwise the code
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
         head
                 titlejQuery AOP Test/title
                 link rel=stylesheet type=text/css media=screen
 href=test.css /
                 script 
 src=http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/
 jquery.min.js/script!-- does not work --
                 !-- script src=jquery-1.3.2.js/script --!-- works --
                 script
                         if(typeof(jQuery)!=undefined){
                             alert('jQuery available');
                         }else{
                                 alert('jQuery not available yet');
                         }
                 /script
                 script src=../src/aop.js/script
                 script src=test.core.js/script
         script
                 function Init(){
                         alert('Init starting');
                         
 jQuery.aop.after({target:document,method:'getElementById'},function
 (){alert('Advice for getElementById called');});
                         var a=document.getElementById('tblError');
                 }
         /script
         /head
         body onload='Init();'
                 script
                     $(document).ready(function() {
                         alert('Document is ready');
                     });
                 /script
                         div id='tblError'pmy error table/p/div
         /body
 /html
 reports jQuery not availale yet and the rest is history as aop.js
 and the code needs jQuery to be loaded

 If I use script src=jquery-1.3.2.js/script --!-- works --
 locally it works fine.

 So the question is qhen is jQuery available? I am running in IR8. I
 have finddled with all the security settings to no avail

 In Firefox, it just works.

 Thanks for your help
 WHat is going


[jQuery] Re: Question about Tutorial: Find me: Using selectors and events

2009-05-23 Thread mkmanning

A quick look in the jQuery source is always a good start:

hover: function(fnOver, fnOut) {
return this.mouseenter(fnOver).mouseleave(fnOut);
}

On May 22, 9:28 pm, Mattsson carol.matts...@gmail.com wrote:
 Hello, I'm very new to jQuery and trying out some of the tutorials.
 In this tutorial,http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
 there is an 
 exercise:http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
 and I have a question about this snipped of code:

 $(document).ready(function() {
    $(#orderedlist li:last).hover(function() {
      $(this).addClass(green);
    },function(){
      $(this).removeClass(green);
    });
  });

 As described in the tutorial, this code will add and remove the green
 class when the user hovers the li element, but only on the last
 element in the list.

 The hover works as we'd want it to: the removeClass isn't executed
 until the hover ends.

 My question is: Why is the execution of the removeClass delayed until
 the hover ends?

 I'm interested in the answer at this early stage of my learning
 because I think knowing the answer will help me understand how jQuery
 executes.

 Thanks,
 Carol


[jQuery] Re: How can i write js equals to $('document').ready()?

2009-05-22 Thread mkmanning

There are other non-library solutions to domready out there:

One of the first:
http://dean.edwards.name/weblog/2006/06/again/
or taken from Mootools:
http://snipplr.com/view/6029/domreadyjs/
etc.

Just Google domready, and as Richard said, look at jQuery's source.


On May 21, 6:25 pm, Michael Liao askxuef...@gmail.com wrote:
 Hi
 I am using jquery, but in some pages I cannot use it but I need to
 write js code like:

 $('document').ready(myInitFunction)

 How can i write js to do this work? is it document.onLoad() event?
 thanks!


[jQuery] Re: Issue with setting click event functions in a for loop

2009-05-16 Thread mkmanning

You might want to doublecheck that when you click the elements you
took out of the loop, you really get what you say. Given your example,
if you click #page2 it should alert 'page3' also.

You don't really need the loop to attach the click and get at the
number if it's part of the id:

$('div[id^=page]').click(function(){
  console.log('page ' + this.id.replace(/page/,'') + ' clicked.');
});

Try Googling global variables, scope, and closures in JavaScript.


On May 16, 2:16 pm, mikfig mikfi...@gmail.com wrote:
 I have a webpage that searches a database using a php script to search
 the database and a jQuery app on the page to retrieve the results and
 show them. So it works fine, but then I want to add page number
 buttons to allow the user to go to different pages of the results.
 So I have a DIV with the id of page_buttons and I use the following
 code:http://pastebin.com/m3dffbf99

 I use the offset and the results per page like this in a MySQL query
 in the php script: SELECT  LIMIT offset,
 resultsPerPage by the way.

 So anyways, the problem I am having is that if I have a loop like
 this:

 var pageNum = 6;
 ...
 for(var i = 0; i = pageNum; ++i)
 {
     $(#page + i).click(function() { alert('page ' + i + '
 clicked.'); });

 }

 The elements with IDs of page1, page2,... are buttons, and I
 tested the above loop. What happens is if I click any of the buttons
 with IDs of page1, page2,.. then they all alert with the string
 page 7 clicked. All the page buttons 1-6 display the string page 7
 clicked.

 To try to greater understand this problem I took the functionality out
 of the loop like this:

 var i = 2;
 $(#page + i).click(function() { alert('page ' + i + '
 clicked.'); });
 i = 3;
 $(#page + i).click(function() { alert('page ' + i + '
 clicked.'); });

 and it worked just fine with page2 alerting page 2 clicked and
 page3 alerting with page 3 clicked.

 So I was hoping someone could help me in explaining why this issue
 occurs and if there was a better way to do what I'm trying to do.

 Thanks,
 mikfig


[jQuery] Re: Slide to fade, can you help me quick? Noob alert!

2009-05-16 Thread mkmanning

You can make your own:

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

Probably a little beyond you right now, but study it and check out the
docs.

HTH :)

On May 16, 9:50 am, Sobering stefan.sober...@gmail.com wrote:
 Hey guys,

 I'm building a site for the company I work at. I'm a pretty
 experienced web designer and coder (as far as standards compliant html/
 css goes), but I'm a complete noob to javascript  jQuery, but I'm
 trying.

 I found this snippet of code online:

 $(document).ready(function(){
         $(.loginToggle).click(function(){
                 $(#loginForm).slideToggle(slow);
         });

 });

 Right now, as you can probably tell, when you click the link with the
 class .loginToggle it slides open the div with the ID #loginForm form
 which is set to display: none; by default. What I want it to do
 instead of sliding is fading in and out when the link is clicked.

 In the current code it says slideToggle, so being the noob I am, I
 tried changing it to fadeToggle with no success. I'm pretty positive
 that this should be an easy solution.

 I'd highly appreciate any help you guys can give!

 Cheers, Sobering


[jQuery] Re: Slide to fade, can you help me quick? Noob alert!

2009-05-16 Thread mkmanning

Btw, you could also combine both effects:

jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle', height: 'toggle'}, speed,
easing, callback);
};

On May 16, 9:49 pm, mkmanning michaell...@gmail.com wrote:
 You can make your own:

 jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle'}, speed, easing, callback);

 };

 Probably a little beyond you right now, but study it and check out the
 docs.

 HTH :)

 On May 16, 9:50 am, Sobering stefan.sober...@gmail.com wrote:

  Hey guys,

  I'm building a site for the company I work at. I'm a pretty
  experienced web designer and coder (as far as standards compliant html/
  css goes), but I'm a complete noob to javascript  jQuery, but I'm
  trying.

  I found this snippet of code online:

  $(document).ready(function(){
          $(.loginToggle).click(function(){
                  $(#loginForm).slideToggle(slow);
          });

  });

  Right now, as you can probably tell, when you click the link with the
  class .loginToggle it slides open the div with the ID #loginForm form
  which is set to display: none; by default. What I want it to do
  instead of sliding is fading in and out when the link is clicked.

  In the current code it says slideToggle, so being the noob I am, I
  tried changing it to fadeToggle with no success. I'm pretty positive
  that this should be an easy solution.

  I'd highly appreciate any help you guys can give!

  Cheers, Sobering


[jQuery] Re: efficient way to find a parent

2009-05-06 Thread mkmanning

.parent() gets you the immediate parent of the element, .parents()
traverses up through all ancestors, so you could use .parents('.user')
and it wouldn't matter how deep you nest the link. You can also
use .closest(), which finds the closest parent that matches the
specified selector:

$(this).closest('.user').attr('id')

Check out the docs for traversing http://docs.jquery.com/Traversing


On May 5, 7:49 pm, jquerysk sh.koiz...@gmail.com wrote:
 I want to find a parent for a button.
 I have set up the html like the following.
 div id='user_123' class='user'
 h1My name goes here/h1
 psome description/p
 a href='Javascript:{}' class='select'
 /div

 The thing is that I need to specify how many steps I have to go up to
 get
 the
 parent id( see the bottom ) and if I add another tag I migh have to
 change
 this source. Is there any way to
 specify using class ( maybe $(this).parent(.user).attr(id) ?) so
 that I
 don't need
 to specify how many level I have to go up in order to get that id?

 $().ready(function(){
 $(.select).click(function(){
     alert($(this).parent().attr(id));

 });
 });

 Thanks in advance.


[jQuery] Re: How to select all text in a div except ul

2009-05-05 Thread mkmanning

Yeah, sorry for the confusion; I should type more slowly :P

That does read badly. Should be don't use .text(). Period. Using my
original example, you'll get an array-like object...
Thanks for pointing that out though, I wouldn't want to confuse
anyone.



On May 5, 9:29 am, Karl Swedberg k...@englishrules.com wrote:
 Sorry, I must have misunderstood the context. I was responding to this:

  Don't use .text(), you'll get an array-like object of text nodes

 It seemed like you were saying that .text() returns an array-like  
 object. But if it's used as a getter (without an argument), it returns  
 a string. If there is more than one element in the jQuery object, it  
 concatenates the text values. So, given the OP's markup, doing $('div  
 li').text() would return SymphilisGhonoreahAids. Anyway, I know you  
 already know this. Just trying to clarify for others who are newer.  
 Hope I didn't muddy the water even more.

 @nick, Another way to get Free sex out of that div is to do this:

 $('div')[0].firstChild.nodeValue

 That will give you leading and trailing white space, though, so you  
 can use jQuery's trim function to strip it:

 $.trim( $('div')[0].firstChild.nodeValue );

 You'll have to adjust the selector, too, if that div isn't the first  
 one in your document.

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On May 4, 2009, at 9:29 PM, mkmanning wrote:



  Sorry, maybe my response was somewhat confusing, but I don't believe
  you'll get a concatenated string (as the OP's followup indicates).

  After using .filter(), you'll get an array-like object (it's still the
  jQuery object) which contains the text nodes.
  Calling .text() on those won't actually concatenate them though, as
  they're text nodes.

  Likewise, if you do $('div').contents().text() you'll only get the
  text of the UL element, rather than a concatenation of that with the
  previous text node.

  @nick, you can get the text from the object with text[0].nodeValue.

  HTH :)

  On May 3, 4:08 pm, Karl Swedberg k...@englishrules.com wrote:
  On May 2, 2009, at 9:28 PM, mkmanning wrote:

  Don't use .text(), you'll get an array-like object of text nodes.

  Tiny clarification: you'll get a concatenated string of text nodes.

  --Karl

  
  Karl Swedbergwww.englishrules.comwww.learningjquery.com

  On May 2, 2009, at 9:28 PM, mkmanning wrote:

  Don't use .text(), you'll get an array-like object of text nodes.  
  Try

  var text = $('div').contents().filter(function(){return
  this.nodeType==3;});
  console.log(text)

  On May 2, 6:06 pm, nick nboutel...@gmail.com wrote:
  Thanks for the response. Are you sure thats correct though?

  alert($('div').contents().filter(function(){return
  this.nodeType==3;}).text());

  returns empty.


[jQuery] Re: The jQuery Object, Namespaces, and Program Modules -- Connecting the Dots Between jQuery and Javascript

2009-05-05 Thread mkmanning

(function($) {$.fn.METHOD_NAME = function() {FUNCTION_CODE}})
(jQuery);

It's a self-invoking anonymous function passing the global jQuery
object as an argument so that it can be referenced inside the function
as '$'. $.fn is simply equivalent to $.prototype (which ==
jQuery.prototype).

Google self-invoking anonymous function and you should get a fair
amount of info.

HTH :)


On May 5, 1:38 pm, kiusau kiu...@mac.com wrote:
 On May 5, 11:04 am, Rey Bango r...@reybango.com wrote:

  Another option would be to break down in greater detail the areas that
  you'd like better clarity on. Unfortunately, your original message was
  quite vague  in terms of helping us optimize our time, you'll need to
  make the effort to better verbalize what you'd like help with.

 All right, please allow me to start over:

 QUESTION:  If a lone pair of parentheses can be used to automatically
 call a function, then what does it mean when two pairs are juxtaposed
 in the same statement as follows:  ()(jQuery);?

 BACKGROUND:  I have recently learned that any named or anonymous
 JavaScript function can be made into a named jQuery method according
 to the following reassignment

 (function($) {$.fn.METHOD_NAME = function() {FUNCTION_CODE}})(jQuery);

 A significant portion of this statement I can easily recognize as
 JavaScript -- namely,

 $.fn.METHOD_NAME = function() {FUNCTION_CODE};

 where function() {FUNCTION_CODE} is an anonymous function assigned to
 the object $.fn as a method named METHOD-NAME.

 I can also understand the phrasing

 function($) { }

 where $ is some parameter assigned to an unnamed function.  If I have
 understood correctly $ is an alias for the jQuery object that is
 passed to this unnamed function.

 What I do not understand is the following unusual construction: ()
 (jQuery);

 If I remember correctly, a single, empty pair of parentheses can be
 used at the end of a function statement to automatically load a
 function.  I believe the format is:

 function( ) {
   FUNCTION_CODE;}

 ();

 The construction ()(jQuery); is, however, none of what I recognize as
 JavaScript.  Can someone explain it?

 Roddy


[jQuery] Re: How To Get Around: Access to restricted URI denied code: 1012

2009-05-05 Thread mkmanning

No options with Ajax cross-domain (for now). If you can change the
service to wrap the XML in a function call or assign it to a variable
you can use $.getScript().

predefine a function or method:

my_function(xml){
//do something with the xml
}

call .getScript():

$.getScript(http://wcf.msts.com/WcfService.svc/GetSponsorSearch?
keyword=treventsessionid=2)

which would return js:

my_function('your xml here');

Alternately you can use a variable (ie return var='your xml') and use
the .getScript() callback function.

HTH :)

On May 5, 5:39 pm, bittermonkey brakes...@gmail.com wrote:
 I was wondering if I have another option without going this route?

 On May 5, 5:08 pm, James james.gp@gmail.com wrote:

  What about going through a proxy (e.g. a PHP script that fetches the
  XML content from wcf.mstsc.com domain) hosted on your current domain?

  On May 5, 11:01 am, bittermonkey brakes...@gmail.com wrote:

   Hi,

   Here's my code:

                   $.ajax({
                       type: GET,
                       url: http://wcf.msts.com/WcfService.svc/
   GetSponsorSearch?keyword=treventsessionid=2,
                       dataType: xml,
                       success: function(xml) {
                           alert(xml);
                       }
                   }); //end ajax call

   I know this is a cross-domain issue but I can't get away with our
   current network setup.  wcf.mstsc.com is where all our web services
   reside.  Is there a way I can make the ajax method work, using XML as
   the return data type, if it's in a different domain?  I'm open to a
   different jquery method (as long as it returns XML) if there is one.

   Thanks in advance.


[jQuery] Re: problem with wrapper arrays.......

2009-05-05 Thread mkmanning

Accessing the elements by index returns the element itself. To call
jQuery methods you'd need to do this:
divs = $('div');
div2 = divs[2];
$(div2).addClass('red');

or alternately you could do:

div2 = $(divs[2]);
div2.addClass('red');

you can also use .eq(#):
div2 = divs.eq(2)
div2.addClass('red');



On May 5, 6:42 pm, kali maya778...@yahoo.com wrote:
 my understanding (acc. to book jQuey in Action and other sources,
 likehttp://jquery.open2space.com/node/10) is that the standard jQuery
 wrapper always returns an array containing all matching elements..
 however, for some very odd reason I can't get an element by referring
 to its index in the array...

 for example:

         divs = $('div');
         div2 = divs[2];              // this line is ignored (or SOMETHING
 weird is happening here..)
 //      div2.addClass('red');   // so get error here that 'div2.addClass'
 is not a function..

 have a page with above code (and other code) 
 here,http://www.mayacove.com/dev/jquery/arrays.html

 am stumped here, have been dealing with this for days..  don't get
 what's happening here (using jQuery version 1.2.1 (maybe this only
 works in 1.3?))

 now this is actually not a huge deal b/c in troubleshooting this have
 found other methods (like filter :eq and other methods.. but still, I
 think it's strange that I can't make it work with array index..)

 thank you...


[jQuery] Re: How to select all text in a div except ul

2009-05-04 Thread mkmanning

Sorry, maybe my response was somewhat confusing, but I don't believe
you'll get a concatenated string (as the OP's followup indicates).

After using .filter(), you'll get an array-like object (it's still the
jQuery object) which contains the text nodes.
Calling .text() on those won't actually concatenate them though, as
they're text nodes.

Likewise, if you do $('div').contents().text() you'll only get the
text of the UL element, rather than a concatenation of that with the
previous text node.

@nick, you can get the text from the object with text[0].nodeValue.

HTH :)

On May 3, 4:08 pm, Karl Swedberg k...@englishrules.com wrote:
 On May 2, 2009, at 9:28 PM, mkmanning wrote:

  Don't use .text(), you'll get an array-like object of text nodes.

 Tiny clarification: you'll get a concatenated string of text nodes.

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com

 On May 2, 2009, at 9:28 PM, mkmanning wrote:



  Don't use .text(), you'll get an array-like object of text nodes. Try

  var text = $('div').contents().filter(function(){return
  this.nodeType==3;});
  console.log(text)

  On May 2, 6:06 pm, nick nboutel...@gmail.com wrote:
  Thanks for the response. Are you sure thats correct though?

  alert($('div').contents().filter(function(){return
  this.nodeType==3;}).text());

  returns empty.


[jQuery] Re: any error in the code..... please check

2009-05-02 Thread mkmanning
You spelled function 'funtion' and the first thing you do is return
false, so everything after that is ignored--by js and me :)

On May 2, 12:39 am, Amit amit.mca...@gmail.com wrote:
 $(document).ready(
         funtion(){
         return false;
             $(#send).click(
                 function(){
                     $.post(lib/ajax/requests.php,
                                 {
                                     action: postrecommendmypros,
                                     projectname: {ALL_SEARCH_TXT},
                                     firstname: {CLIENT_FIRSTNAME},
                                     lastname: {CLIENT_LASTNAME},
                                     id: {CLIENT_LASTNAME},
                                     project_id: {ALL_REQUEST_PID},
                                     url:{ALL_MY_REQUESTS_REDIRECT},
                                     id: {EMAIL_UID}
                                 },
                                 function(data){
                                     
 window.location={ALL_MY_REQUESTS_REDIRECT};
                                 }
                         );                   
                     return false;
                 }
                 showNotice('Response posted!','Project '+ projectname);
             );
         }
     );   --

 Regards,



 Amit Kr. Sharma



 Mobile: 09780141161



 Profile:  http://www.linkedin.com/in/amit2sharma



 Email id: amit.mca...@gmail.com



  



[jQuery] Re: How to select all text in a div except ul

2009-05-02 Thread mkmanning

Don't use .text(), you'll get an array-like object of text nodes. Try

var text = $('div').contents().filter(function(){return
this.nodeType==3;});
console.log(text)


On May 2, 6:06 pm, nick nboutel...@gmail.com wrote:
 Thanks for the response. Are you sure thats correct though?

 alert($('div').contents().filter(function(){return
 this.nodeType==3;}).text());

 returns empty.


[jQuery] Re: extract base url

2009-05-01 Thread mkmanning

If that's all you need for the search property, then just use
window.location.host + '?key=val#'

On May 1, 1:39 pm, buntu buntu.w...@gmail.com wrote:
 Here is an example:

 I need to append '?key=val1' to the current url which is
  www.mysite.com/web/test.html

 and this I can do using:
   window.location.href+'?key=val1' resulting 
 inwww.mysite.com/web/test.html?key=val1

 I now need a  way to modify val1 to val2, if I do:
   window.location.href+'?key=val2' results in  
 www.mysite.com/web/test.html?key=val1?key=val2

 but I need:  www.mysite.com/web/test.html?key=val2

 There are ways to break down the url but wanted to know if there is
 anything jQuery already provides. Thanks!

 On May 1, 1:22 pm, waseem sabjee waseemsab...@gmail.com wrote:

  ok so you wanna edit the URL ?

  var url = www.google.co.za;
  top.location = url;

  this will send the page towww.google.co.za

  var url  top.location;

  this shoud retrieve the URL

  Sorry. I'm unable to fully answer your question at this time.

  On Fri, May 1, 2009 at 10:17 PM, buntu buntu.w...@gmail.com wrote:

   Hi,

   I need to append a parameter string like: '?key=val' to the current
   url and the value for the key changes based on the user input. Is
   there any jquery utility that does the base url extraction from
   window.location, so that I can append the '?key=val' to that?

   Thanks for the help!


[jQuery] Re: How to select all text in a div except ul

2009-05-01 Thread mkmanning

To get just the text nodes:
$('div').contents().filter(function(){return this.nodeType==3;});

If you want to filter out 'empty' nodes:
$('div').contents().filter(function(){return this.nodeType==3 
this.nodeValue.replace(/\W/g,'')!='';});

Take it from there :)

On May 1, 4:06 pm, nick nboutel...@gmail.com wrote:
 How would I select Free sex out of...

 div
    Free sex
    ul
       liSymphilis/li
       liGhonoreah/li
       liAids/li
    /ul
 /div


[jQuery] Re: Animate Variable Concatenate Help

2009-04-30 Thread mkmanning

There is no second half of my function, those are two distinct
functions. A variable declared with 'var' in the first one isn't
available to the second (without the 'var' it's global and would be
available, but that's not recommended). You can use .data() to store
the width and retrieve it in the second function.

On Apr 30, 12:38 pm, paper_robots mresto...@gmail.com wrote:
 I tried that initially. It didn't work. I think my variable isn't
 being recognized by the second half of my function. I get this error
 in firebug.. mywidth is not defined. But if I alert it in the upper
 half I get a value.

 On Apr 30, 2:15 pm, pete higgins phigg...@gmail.com wrote:

  $(this).animate({ width: mywidth + px });

  think:

  var newwidth = {
     width: mywidth + px

  }

  Regards

  On Thu, Apr 30, 2009 at 5:54 PM, paper_robots mresto...@gmail.com wrote:

   I'm trying to get the width of an element, animate it bigger, then
   shrink it back to normal size on hover. Here's my function:

   $('a.slider').hover(function(){
                  var mywidth = $(this).width();
                  $(this).animate({width: 240px});
          }, function(){
                  $(this).animate({width: +mywidth+px});
          });

   The line I'm having trouble with is:
   $(this).animate({width: +mywidth+px});

   I know its not concatenated right, but I tried a few ways and couldn't
   get it to work. What am I doing wrong? Thanks in advanced!


[jQuery] Re: Grabbing text inside an alt tag

2009-04-29 Thread mkmanning

A couple thoughts:

'alt' isn't a valid attribute of span; use 'title'.

Using jQuery doesn't necessarily equate to easier.

//POJS
for (var i = 0; i  elem.length; i++) {
  if(!elem[i].title){elem[i].title=;}
}

//jQuery
$('span').each(function(){
  if(!this.title){this.title=;}
});

On Apr 29, 3:17 pm, Andy adharb...@gmail.com wrote:
 Is there a way to grab the text from inside a alt tag?  I have a site
 that will have tons of span tags and I need to go through all of them
 searching for the alt= attribute then grab it.

 I'm using some non-jQuery javascript, so I'm sure there is an easier
 way to format this than what I currently have.  Any thoughts on this
 would be great.

 - html example:

 spantext here/span
 span alt=Joetext here/span
 span alt=Jimtext here/span
 spantext here/span

 - Javascript.

 // grab all spans on page.
 var elem = window.opener.document.getElementsByTagName(span);

 // make sure spans have alt attribute
 for (var i = 0; i  elem.length; i++) {
        if (!!$(elem[i]).attr(printElement)) {

                 Where do I go from here?
                . would like to do a document.write(span element
 alt value);

        }

 }

 Any thoughts on this would be great.


[jQuery] Re: find and replace

2009-04-28 Thread mkmanning

Use a regex:

$('body').html( $('body').html().replace(/(that|your)/g,'b$1/
b') );



On Apr 28, 9:39 am, kazim mehdi kazim.me...@gmail.com wrote:
 hi
 by using the following code  i am able to find only first occurrences
 of the keywords can anyone help me to make it work for all of the
 occurrences.

 thank you

 function test()
                 {
                         var keywords = [got, the];
                         var el = $(body);
                         $(keywords).each(function()
                         {
                                 el.html(el.html().replace(this, 
 b+this+/b));
                         });

                 }


  1   2   3   4   >