[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

I am pulling my hair out over this.  I swear that this is a bug.

For some reason, I CANNOT target any forms within the html response.
I have tried very simple examples and it still won't work.  Here is
what I have, that still returns undefined:

HTML:
form id=test action=http://test.com;
span id=test2this is my text/span
/form

jQuery:
success: function(html){
  alert($(html).find(#test).attr('action'));
  alert($(html).find(#test2).text());
}

#test2 works, but #test never does, and it seems this is because it is
a form.  Have I done something wrong here?  Can I not target a form?

On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 I have an ajax GET call that returns the HTML of a page on my server.
 Within that page is a form with a specific ID.  I know it is there, I
 can see it in the response in Firebug, but when I try to get
 attributes of that ID, it always returns undefined!  What have I done
 wrong here?

 success: function(html){

 $(html).find('#main_form').each(function() {
 var linking_data = $(this).serialize();
 var form_action = $(this).attr('action');
 alert(form_action);

 });
 }

 I have tried to not use each() and that still returns undefined.  I
 don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Test page to show the problem: http://www.puc.edu/dev/tests/ajax-test

On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:
 I am pulling my hair out over this.  I swear that this is a bug.

 For some reason, I CANNOT target any forms within the html response.
 I have tried very simple examples and it still won't work.  Here is
 what I have, that still returns undefined:

 HTML:
 form id=test action=http://test.com;
 span id=test2this is my text/span
 /form

 jQuery:
 success: function(html){
   alert($(html).find(#test).attr('action'));
   alert($(html).find(#test2).text());

 }

 #test2 works, but #test never does, and it seems this is because it is
 a form.  Have I done something wrong here?  Can I not target a form?

 On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  I have an ajax GET call that returns the HTML of a page on my server.
  Within that page is a form with a specific ID.  I know it is there, I
  can see it in the response in Firebug, but when I try to get
  attributes of that ID, it always returns undefined!  What have I done
  wrong here?

  success: function(html){

  $(html).find('#main_form').each(function() {
  var linking_data = $(this).serialize();
  var form_action = $(this).attr('action');
  alert(form_action);

  });
  }

  I have tried to not use each() and that still returns undefined.  I
  don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Ryan

If I understand correctly what you are tring to do, I think what you
are looking for is the live() event

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



On Apr 13, 5:47 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

  I am pulling my hair out over this.  I swear that this is a bug.

  For some reason, I CANNOT target any forms within the html response.
  I have tried very simple examples and it still won't work.  Here is
  what I have, that still returns undefined:

  HTML:
  form id=test action=http://test.com;
  span id=test2this is my text/span
  /form

  jQuery:
  success: function(html){
    alert($(html).find(#test).attr('action'));
    alert($(html).find(#test2).text());

  }

  #test2 works, but #test never does, and it seems this is because it is
  a form.  Have I done something wrong here?  Can I not target a form?

  On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   I have an ajax GET call that returns the HTML of a page on my server.
   Within that page is a form with a specific ID.  I know it is there, I
   can see it in the response in Firebug, but when I try to get
   attributes of that ID, it always returns undefined!  What have I done
   wrong here?

   success: function(html){

   $(html).find('#main_form').each(function() {
   var linking_data = $(this).serialize();
   var form_action = $(this).attr('action');
   alert(form_action);

   });
   }

   I have tried to not use each() and that still returns undefined.  I
   don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nathan


You could try changing this: alert($(html).find(#test).attr
('action'));
To This: alert($(#test).attr('action'));


On Apr 13, 9:47 am, Nic Hubbard nnhubb...@gmail.com wrote:
 Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:



  I am pulling my hair out over this.  I swear that this is a bug.

  For some reason, I CANNOT target any forms within the html response.
  I have tried very simple examples and it still won't work.  Here is
  what I have, that still returns undefined:

  HTML:
  form id=test action=http://test.com;
  span id=test2this is my text/span
  /form

  jQuery:
  success: function(html){
    alert($(html).find(#test).attr('action'));
    alert($(html).find(#test2).text());

  }

  #test2 works, but #test never does, and it seems this is because it is
  a form.  Have I done something wrong here?  Can I not target a form?

  On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   I have an ajax GET call that returns the HTML of a page on my server.
   Within that page is a form with a specific ID.  I know it is there, I
   can see it in the response in Firebug, but when I try to get
   attributes of that ID, it always returns undefined!  What have I done
   wrong here?

   success: function(html){

   $(html).find('#main_form').each(function() {
   var linking_data = $(this).serialize();
   var form_action = $(this).attr('action');
   alert(form_action);

   });
   }

   I have tried to not use each() and that still returns undefined.  I
   don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Nope, that does not work either.

On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
 Maybe try:

 success: function(html){
   alert($(html).find('form').attr('action'));

 I had some issues in the past using form id's with the jquery form
 plugin, but usually getting it using 'form' worked.

 That said, since the response isn't in the DOM yet, I'm not sure if that
 might present an issue (too/instead).

 - Jack

 Nic Hubbard wrote:
  Yes, this is very odd. I have tried it quite a few ways, but I can
  never target the form.  Any other ideas?

  It is frustrating because I really need to target a form in the html
  response...

  On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

  That's strange. I can't get it to work either and I'm getting the same
  results as you (I can get #test2, but not #test). I've even truncated
  the response down to as if you're only receiving the form part and
  it still doesn't work. I'd be interested in seeing what happens here
  too.

  On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

  On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

  I am pulling my hair out over this.  I swear that this is a bug.

  For some reason, I CANNOT target any forms within the html response.
  I have tried very simple examples and it still won't work.  Here is
  what I have, that still returns undefined:

  HTML:
  form id=test action=http://test.com;
  span id=test2this is my text/span
  /form

  jQuery:
  success: function(html){
    alert($(html).find(#test).attr('action'));
    alert($(html).find(#test2).text());

  }

  #test2 works, but #test never does, and it seems this is because it is
  a form.  Have I done something wrong here?  Can I not target a form?

  On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  I have an ajax GET call that returns the HTML of a page on my server.
  Within that page is a form with a specific ID.  I know it is there, I
  can see it in the response in Firebug, but when I try to get
  attributes of that ID, it always returns undefined!  What have I done
  wrong here?

  success: function(html){

  $(html).find('#main_form').each(function() {
  var linking_data = $(this).serialize();
  var form_action = $(this).attr('action');
  alert(form_action);

  });
  }

  I have tried to not use each() and that still returns undefined.  I
  don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Nope, that returns undefined as well. :(

On Apr 13, 11:34 am, Nathan nsear...@gmail.com wrote:
 You could try changing this: alert($(html).find(#test).attr
 ('action'));
 To This: alert($(#test).attr('action'));

 On Apr 13, 9:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

  On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

   I am pulling my hair out over this.  I swear that this is a bug.

   For some reason, I CANNOT target any forms within the html response.
   I have tried very simple examples and it still won't work.  Here is
   what I have, that still returns undefined:

   HTML:
   form id=test action=http://test.com;
   span id=test2this is my text/span
   /form

   jQuery:
   success: function(html){
     alert($(html).find(#test).attr('action'));
     alert($(html).find(#test2).text());

   }

   #test2 works, but #test never does, and it seems this is because it is
   a form.  Have I done something wrong here?  Can I not target a form?

   On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

I have an ajax GET call that returns the HTML of a page on my server.
Within that page is a form with a specific ID.  I know it is there, I
can see it in the response in Firebug, but when I try to get
attributes of that ID, it always returns undefined!  What have I done
wrong here?

success: function(html){

$(html).find('#main_form').each(function() {
var linking_data = $(this).serialize();
var form_action = $(this).attr('action');
alert(form_action);

});
}

I have tried to not use each() and that still returns undefined.  I
don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Jack Killpatrick

Maybe try:

success: function(html){
 alert($(html).find('form').attr('action'));

I had some issues in the past using form id's with the jquery form 
plugin, but usually getting it using 'form' worked.


That said, since the response isn't in the DOM yet, I'm not sure if that 
might present an issue (too/instead).


- Jack

Nic Hubbard wrote:

Yes, this is very odd. I have tried it quite a few ways, but I can
never target the form.  Any other ideas?

It is frustrating because I really need to target a form in the html
response...

On Apr 13, 11:45 am, James james.gp@gmail.com wrote:
  

That's strange. I can't get it to work either and I'm getting the same
results as you (I can get #test2, but not #test). I've even truncated
the response down to as if you're only receiving the form part and
it still doesn't work. I'd be interested in seeing what happens here
too.

On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:



Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test
  
On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:
  

I am pulling my hair out over this.  I swear that this is a bug.

For some reason, I CANNOT target any forms within the html response.

I have tried very simple examples and it still won't work.  Here is
what I have, that still returns undefined:

HTML:

form id=test action=http://test.com;
span id=test2this is my text/span
/form

jQuery:

success: function(html){
  alert($(html).find(#test).attr('action'));
  alert($(html).find(#test2).text());

}

#test2 works, but #test never does, and it seems this is because it is

a form.  Have I done something wrong here?  Can I not target a form?

On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:


I have an ajax GET call that returns the HTML of a page on my server.
Within that page is a form with a specific ID.  I know it is there, I
can see it in the response in Firebug, but when I try to get
attributes of that ID, it always returns undefined!  What have I done
wrong here?
  
success: function(html){
  
$(html).find('#main_form').each(function() {

var linking_data = $(this).serialize();
var form_action = $(this).attr('action');
alert(form_action);
  
});

}
  
I have tried to not use each() and that still returns undefined.  I

don't get it.
  


  




[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Yes, this is very odd. I have tried it quite a few ways, but I can
never target the form.  Any other ideas?

It is frustrating because I really need to target a form in the html
response...

On Apr 13, 11:45 am, James james.gp@gmail.com wrote:
 That's strange. I can't get it to work either and I'm getting the same
 results as you (I can get #test2, but not #test). I've even truncated
 the response down to as if you're only receiving the form part and
 it still doesn't work. I'd be interested in seeing what happens here
 too.

 On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

  On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

   I am pulling my hair out over this.  I swear that this is a bug.

   For some reason, I CANNOT target any forms within the html response.
   I have tried very simple examples and it still won't work.  Here is
   what I have, that still returns undefined:

   HTML:
   form id=test action=http://test.com;
   span id=test2this is my text/span
   /form

   jQuery:
   success: function(html){
     alert($(html).find(#test).attr('action'));
     alert($(html).find(#test2).text());

   }

   #test2 works, but #test never does, and it seems this is because it is
   a form.  Have I done something wrong here?  Can I not target a form?

   On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

I have an ajax GET call that returns the HTML of a page on my server.
Within that page is a form with a specific ID.  I know it is there, I
can see it in the response in Firebug, but when I try to get
attributes of that ID, it always returns undefined!  What have I done
wrong here?

success: function(html){

$(html).find('#main_form').each(function() {
var linking_data = $(this).serialize();
var form_action = $(this).attr('action');
alert(form_action);

});
}

I have tried to not use each() and that still returns undefined.  I
don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread James

That's strange. I can't get it to work either and I'm getting the same
results as you (I can get #test2, but not #test). I've even truncated
the response down to as if you're only receiving the form part and
it still doesn't work. I'd be interested in seeing what happens here
too.


On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:
 Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

  I am pulling my hair out over this.  I swear that this is a bug.

  For some reason, I CANNOT target any forms within the html response.
  I have tried very simple examples and it still won't work.  Here is
  what I have, that still returns undefined:

  HTML:
  form id=test action=http://test.com;
  span id=test2this is my text/span
  /form

  jQuery:
  success: function(html){
    alert($(html).find(#test).attr('action'));
    alert($(html).find(#test2).text());

  }

  #test2 works, but #test never does, and it seems this is because it is
  a form.  Have I done something wrong here?  Can I not target a form?

  On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   I have an ajax GET call that returns the HTML of a page on my server.
   Within that page is a form with a specific ID.  I know it is there, I
   can see it in the response in Firebug, but when I try to get
   attributes of that ID, it always returns undefined!  What have I done
   wrong here?

   success: function(html){

   $(html).find('#main_form').each(function() {
   var linking_data = $(this).serialize();
   var form_action = $(this).attr('action');
   alert(form_action);

   });
   }

   I have tried to not use each() and that still returns undefined.  I
   don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Luciano
Hey Nic,

I have a couple small recommendations- hopefully one will fix the issue.

Try using $.get() instead of $.ajax, and specify type option as html-
alternatively, you can use $.load() if your ultimate purpose is to inject
this HTML into DOM.

In addition rather than using find(), just select by ID as a subset of the
DOM node..

alert($(html).find(#test) becomes
alert($(#test, html));

Hope some of this helps... cheers!

Nic Luciano
Senior Web Developer @ AdaptiveBlue
http://www.twitter.com/nicluciano
http://www.linkedin.com/in/nicluciano


On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com wrote:


 Nope, that does not work either.

 On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
  Maybe try:
 
  success: function(html){
alert($(html).find('form').attr('action'));
 
  I had some issues in the past using form id's with the jquery form
  plugin, but usually getting it using 'form' worked.
 
  That said, since the response isn't in the DOM yet, I'm not sure if that
  might present an issue (too/instead).
 
  - Jack
 
  Nic Hubbard wrote:
   Yes, this is very odd. I have tried it quite a few ways, but I can
   never target the form.  Any other ideas?
 
   It is frustrating because I really need to target a form in the html
   response...
 
   On Apr 13, 11:45 am, James james.gp@gmail.com wrote:
 
   That's strange. I can't get it to work either and I'm getting the same
   results as you (I can get #test2, but not #test). I've even truncated
   the response down to as if you're only receiving the form part and
   it still doesn't work. I'd be interested in seeing what happens here
   too.
 
   On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:
 
   Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test
 
   On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:
 
   I am pulling my hair out over this.  I swear that this is a bug.
 
   For some reason, I CANNOT target any forms within the html response.
   I have tried very simple examples and it still won't work.  Here is
   what I have, that still returns undefined:
 
   HTML:
   form id=test action=http://test.com;
   span id=test2this is my text/span
   /form
 
   jQuery:
   success: function(html){
 alert($(html).find(#test).attr('action'));
 alert($(html).find(#test2).text());
 
   }
 
   #test2 works, but #test never does, and it seems this is because it
 is
   a form.  Have I done something wrong here?  Can I not target a form?
 
   On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 
   I have an ajax GET call that returns the HTML of a page on my
 server.
   Within that page is a form with a specific ID.  I know it is there,
 I
   can see it in the response in Firebug, but when I try to get
   attributes of that ID, it always returns undefined!  What have I
 done
   wrong here?
 
   success: function(html){
 
   $(html).find('#main_form').each(function() {
   var linking_data = $(this).serialize();
   var form_action = $(this).attr('action');
   alert(form_action);
 
   });
   }
 
   I have tried to not use each() and that still returns undefined.  I
   don't get it.



[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Ok, my test now reflects your suggestions.  But, sadly, none of that
helped, it is still returning undefined. :(

On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:
 Hey Nic,

 I have a couple small recommendations- hopefully one will fix the issue.

 Try using $.get() instead of $.ajax, and specify type option as html-
 alternatively, you can use $.load() if your ultimate purpose is to inject
 this HTML into DOM.

 In addition rather than using find(), just select by ID as a subset of the
 DOM node..

 alert($(html).find(#test) becomes
 alert($(#test, html));

 Hope some of this helps... cheers!

 Nic Luciano
 Senior Web Developer @ 
 AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

 On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com wrote:

  Nope, that does not work either.

  On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
   Maybe try:

   success: function(html){
     alert($(html).find('form').attr('action'));

   I had some issues in the past using form id's with the jquery form
   plugin, but usually getting it using 'form' worked.

   That said, since the response isn't in the DOM yet, I'm not sure if that
   might present an issue (too/instead).

   - Jack

   Nic Hubbard wrote:
Yes, this is very odd. I have tried it quite a few ways, but I can
never target the form.  Any other ideas?

It is frustrating because I really need to target a form in the html
response...

On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

That's strange. I can't get it to work either and I'm getting the same
results as you (I can get #test2, but not #test). I've even truncated
the response down to as if you're only receiving the form part and
it still doesn't work. I'd be interested in seeing what happens here
too.

On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

I am pulling my hair out over this.  I swear that this is a bug.

For some reason, I CANNOT target any forms within the html response.
I have tried very simple examples and it still won't work.  Here is
what I have, that still returns undefined:

HTML:
form id=test action=http://test.com;
span id=test2this is my text/span
/form

jQuery:
success: function(html){
  alert($(html).find(#test).attr('action'));
  alert($(html).find(#test2).text());

}

#test2 works, but #test never does, and it seems this is because it
  is
a form.  Have I done something wrong here?  Can I not target a form?

On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

I have an ajax GET call that returns the HTML of a page on my
  server.
Within that page is a form with a specific ID.  I know it is there,
  I
can see it in the response in Firebug, but when I try to get
attributes of that ID, it always returns undefined!  What have I
  done
wrong here?

success: function(html){

$(html).find('#main_form').each(function() {
var linking_data = $(this).serialize();
var form_action = $(this).attr('action');
alert(form_action);

});
}

I have tried to not use each() and that still returns undefined.  I
don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread finco

Just a guess here - is it possible that jquery will not recognize
nodes that are loaded after the document is first rendered?  Do you
need to rebind?

On Apr 13, 4:28 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 Ok, my test now reflects your suggestions.  But, sadly, none of that
 helped, it is still returning undefined. :(

 On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:



  Hey Nic,

  I have a couple small recommendations- hopefully one will fix the issue.

  Try using $.get() instead of $.ajax, and specify type option as html-
  alternatively, you can use $.load() if your ultimate purpose is to inject
  this HTML into DOM.

  In addition rather than using find(), just select by ID as a subset of the
  DOM node..

  alert($(html).find(#test) becomes
  alert($(#test, html));

  Hope some of this helps... cheers!

  Nic Luciano
  Senior Web Developer @ 
  AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

  On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com wrote:

   Nope, that does not work either.

   On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
Maybe try:

success: function(html){
  alert($(html).find('form').attr('action'));

I had some issues in the past using form id's with the jquery form
plugin, but usually getting it using 'form' worked.

That said, since the response isn't in the DOM yet, I'm not sure if that
might present an issue (too/instead).

- Jack

Nic Hubbard wrote:
 Yes, this is very odd. I have tried it quite a few ways, but I can
 never target the form.  Any other ideas?

 It is frustrating because I really need to target a form in the html
 response...

 On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

 That's strange. I can't get it to work either and I'm getting the 
 same
 results as you (I can get #test2, but not #test). I've even truncated
 the response down to as if you're only receiving the form part and
 it still doesn't work. I'd be interested in seeing what happens here
 too.

 On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

 Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

 I am pulling my hair out over this.  I swear that this is a bug.

 For some reason, I CANNOT target any forms within the html 
 response.
 I have tried very simple examples and it still won't work.  Here is
 what I have, that still returns undefined:

 HTML:
 form id=test action=http://test.com;
 span id=test2this is my text/span
 /form

 jQuery:
 success: function(html){
   alert($(html).find(#test).attr('action'));
   alert($(html).find(#test2).text());

 }

 #test2 works, but #test never does, and it seems this is because it
   is
 a form.  Have I done something wrong here?  Can I not target a 
 form?

 On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

 I have an ajax GET call that returns the HTML of a page on my
   server.
 Within that page is a form with a specific ID.  I know it is 
 there,
   I
 can see it in the response in Firebug, but when I try to get
 attributes of that ID, it always returns undefined!  What have I
   done
 wrong here?

 success: function(html){

 $(html).find('#main_form').each(function() {
 var linking_data = $(this).serialize();
 var form_action = $(this).attr('action');
 alert(form_action);

 });
 }

 I have tried to not use each() and that still returns undefined.  
 I
 don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread James

I still haven't figured it out, but playing around and setting the
ajax response as a jquery object, $(html), and making it global so I
can view it's attributes through Firebug, I was able to locate the
form element on the ajax response. It was the index-5 element for your
test page. My sample code below. Though this still doesn't help as to
why we can't reference it using #test2, maybe someone else can get
something more out of it.

I've also tried appended the response to the page and still no go.

--

var globalHTML;  // global variable

$(document).ready(function() {

$.ajax({
url: 'http://www.puc.edu/dev/tests/linking-test',
type: 'GET',
success: function(html) {
var $html = $(html);  // wrap response as jquery object

globalHTML = $html;  // check object with firebug

alert( $html.get(5).action );
}
});

});

Using Firebug and looking at the attributes of the object I've found
that the form is on the 5th-index of the object, for your test page.
Though this still doesn't really help much

alert( $(html).get(5).action );

On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:
 Ok, my test now reflects your suggestions.  But, sadly, none of that
 helped, it is still returning undefined. :(

 On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

  Hey Nic,

  I have a couple small recommendations- hopefully one will fix the issue.

  Try using $.get() instead of $.ajax, and specify type option as html-
  alternatively, you can use $.load() if your ultimate purpose is to inject
  this HTML into DOM.

  In addition rather than using find(), just select by ID as a subset of the
  DOM node..

  alert($(html).find(#test) becomes
  alert($(#test, html));

  Hope some of this helps... cheers!

  Nic Luciano
  Senior Web Developer @ 
  AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

  On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com wrote:

   Nope, that does not work either.

   On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
Maybe try:

success: function(html){
  alert($(html).find('form').attr('action'));

I had some issues in the past using form id's with the jquery form
plugin, but usually getting it using 'form' worked.

That said, since the response isn't in the DOM yet, I'm not sure if that
might present an issue (too/instead).

- Jack

Nic Hubbard wrote:
 Yes, this is very odd. I have tried it quite a few ways, but I can
 never target the form.  Any other ideas?

 It is frustrating because I really need to target a form in the html
 response...

 On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

 That's strange. I can't get it to work either and I'm getting the 
 same
 results as you (I can get #test2, but not #test). I've even truncated
 the response down to as if you're only receiving the form part and
 it still doesn't work. I'd be interested in seeing what happens here
 too.

 On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

 Test page to show the problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

 I am pulling my hair out over this.  I swear that this is a bug.

 For some reason, I CANNOT target any forms within the html 
 response.
 I have tried very simple examples and it still won't work.  Here is
 what I have, that still returns undefined:

 HTML:
 form id=test action=http://test.com;
 span id=test2this is my text/span
 /form

 jQuery:
 success: function(html){
   alert($(html).find(#test).attr('action'));
   alert($(html).find(#test2).text());

 }

 #test2 works, but #test never does, and it seems this is because it
   is
 a form.  Have I done something wrong here?  Can I not target a 
 form?

 On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

 I have an ajax GET call that returns the HTML of a page on my
   server.
 Within that page is a form with a specific ID.  I know it is 
 there,
   I
 can see it in the response in Firebug, but when I try to get
 attributes of that ID, it always returns undefined!  What have I
   done
 wrong here?

 success: function(html){

 $(html).find('#main_form').each(function() {
 var linking_data = $(this).serialize();
 var form_action = $(this).attr('action');
 alert(form_action);

 });
 }

 I have tried to not use each() and that still returns undefined.  
 I
 don't get it.


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Could this be a jQuery bug?

On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:
 I still haven't figured it out, but playing around and setting the
 ajax response as a jquery object, $(html), and making it global so I
 can view it's attributes through Firebug, I was able to locate the
 form element on the ajax response. It was the index-5 element for your
 test page. My sample code below. Though this still doesn't help as to
 why we can't reference it using #test2, maybe someone else can get
 something more out of it.

 I've also tried appended the response to the page and still no go.

 --

 var globalHTML;  // global variable

 $(document).ready(function() {

         $.ajax({
                 url: 'http://www.puc.edu/dev/tests/linking-test',
                 type: 'GET',
                 success: function(html) {
                         var $html = $(html);  // wrap response as jquery 
 object

                         globalHTML = $html;  // check object with firebug

                         alert( $html.get(5).action );
                 }
         });

 });

 Using Firebug and looking at the attributes of the object I've found
 that the form is on the 5th-index of the object, for your test page.
 Though this still doesn't really help much

 alert( $(html).get(5).action );

 On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Ok, my test now reflects your suggestions.  But, sadly, none of that
  helped, it is still returning undefined. :(

  On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

   Hey Nic,

   I have a couple small recommendations- hopefully one will fix the issue.

   Try using $.get() instead of $.ajax, and specify type option as html-
   alternatively, you can use $.load() if your ultimate purpose is to inject
   this HTML into DOM.

   In addition rather than using find(), just select by ID as a subset of the
   DOM node..

   alert($(html).find(#test) becomes
   alert($(#test, html));

   Hope some of this helps... cheers!

   Nic Luciano
   Senior Web Developer @ 
   AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

   On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com wrote:

Nope, that does not work either.

On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
 Maybe try:

 success: function(html){
   alert($(html).find('form').attr('action'));

 I had some issues in the past using form id's with the jquery form
 plugin, but usually getting it using 'form' worked.

 That said, since the response isn't in the DOM yet, I'm not sure if 
 that
 might present an issue (too/instead).

 - Jack

 Nic Hubbard wrote:
  Yes, this is very odd. I have tried it quite a few ways, but I can
  never target the form.  Any other ideas?

  It is frustrating because I really need to target a form in the html
  response...

  On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

  That's strange. I can't get it to work either and I'm getting the 
  same
  results as you (I can get #test2, but not #test). I've even 
  truncated
  the response down to as if you're only receiving the form part 
  and
  it still doesn't work. I'd be interested in seeing what happens 
  here
  too.

  On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Test page to show the 
  problem:http://www.puc.edu/dev/tests/ajax-test

  On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

  I am pulling my hair out over this.  I swear that this is a bug.

  For some reason, I CANNOT target any forms within the html 
  response.
  I have tried very simple examples and it still won't work.  Here 
  is
  what I have, that still returns undefined:

  HTML:
  form id=test action=http://test.com;
  span id=test2this is my text/span
  /form

  jQuery:
  success: function(html){
    alert($(html).find(#test).attr('action'));
    alert($(html).find(#test2).text());

  }

  #test2 works, but #test never does, and it seems this is because 
  it
is
  a form.  Have I done something wrong here?  Can I not target a 
  form?

  On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  I have an ajax GET call that returns the HTML of a page on my
server.
  Within that page is a form with a specific ID.  I know it is 
  there,
I
  can see it in the response in Firebug, but when I try to get
  attributes of that ID, it always returns undefined!  What have I
done
  wrong here?

  success: function(html){

  $(html).find('#main_form').each(function() {
  var linking_data = $(this).serialize();
  var form_action = $(this).attr('action');
  alert(form_action);

  });
  }

  I have tried to not use each() and that still returns 
  

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Ryan


If you wrap your form in a div I think it should work - haven't tested
it

R



On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 Could this be a jQuery bug?

 On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

  I still haven't figured it out, but playing around and setting the
  ajax response as a jquery object, $(html), and making it global so I
  can view it's attributes through Firebug, I was able to locate the
  form element on the ajax response. It was the index-5 element for your
  test page. My sample code below. Though this still doesn't help as to
  why we can't reference it using #test2, maybe someone else can get
  something more out of it.

  I've also tried appended the response to the page and still no go.

  --

  var globalHTML;  // global variable

  $(document).ready(function() {

          $.ajax({
                  url: 'http://www.puc.edu/dev/tests/linking-test',
                  type: 'GET',
                  success: function(html) {
                          var $html = $(html);  // wrap response as jquery 
  object

                          globalHTML = $html;  // check object with firebug

                          alert( $html.get(5).action );
                  }
          });

  });

  Using Firebug and looking at the attributes of the object I've found
  that the form is on the 5th-index of the object, for your test page.
  Though this still doesn't really help much

  alert( $(html).get(5).action );

  On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

   Ok, my test now reflects your suggestions.  But, sadly, none of that
   helped, it is still returning undefined. :(

   On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

Hey Nic,

I have a couple small recommendations- hopefully one will fix the issue.

Try using $.get() instead of $.ajax, and specify type option as 
html-
alternatively, you can use $.load() if your ultimate purpose is to 
inject
this HTML into DOM.

In addition rather than using find(), just select by ID as a subset of 
the
DOM node..

alert($(html).find(#test) becomes
alert($(#test, html));

Hope some of this helps... cheers!

Nic Luciano
Senior Web Developer @ 
AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com 
wrote:

 Nope, that does not work either.

 On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
  Maybe try:

  success: function(html){
    alert($(html).find('form').attr('action'));

  I had some issues in the past using form id's with the jquery form
  plugin, but usually getting it using 'form' worked.

  That said, since the response isn't in the DOM yet, I'm not sure if 
  that
  might present an issue (too/instead).

  - Jack

  Nic Hubbard wrote:
   Yes, this is very odd. I have tried it quite a few ways, but I can
   never target the form.  Any other ideas?

   It is frustrating because I really need to target a form in the 
   html
   response...

   On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

   That's strange. I can't get it to work either and I'm getting 
   the same
   results as you (I can get #test2, but not #test). I've even 
   truncated
   the response down to as if you're only receiving the form part 
   and
   it still doesn't work. I'd be interested in seeing what happens 
   here
   too.

   On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

   Test page to show the 
   problem:http://www.puc.edu/dev/tests/ajax-test

   On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

   I am pulling my hair out over this.  I swear that this is a 
   bug.

   For some reason, I CANNOT target any forms within the html 
   response.
   I have tried very simple examples and it still won't work.  
   Here is
   what I have, that still returns undefined:

   HTML:
   form id=test action=http://test.com;
   span id=test2this is my text/span
   /form

   jQuery:
   success: function(html){
     alert($(html).find(#test).attr('action'));
     alert($(html).find(#test2).text());

   }

   #test2 works, but #test never does, and it seems this is 
   because it
 is
   a form.  Have I done something wrong here?  Can I not target a 
   form?

   On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   I have an ajax GET call that returns the HTML of a page on my
 server.
   Within that page is a form with a specific ID.  I know it is 
   there,
 I
   can see it in the response in Firebug, but when I try to get
   attributes of that ID, it always returns undefined!  What 
   have I
 done
   wrong here?


[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Hey, that actually worked!  But, why would this have helped?  And, is
there a way around this, since the real form that I need to get, I
cannot wrap a div around.

On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:
 If you wrap your form in a div I think it should work - haven't tested
 it

 R

 On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  Could this be a jQuery bug?

  On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

   I still haven't figured it out, but playing around and setting the
   ajax response as a jquery object, $(html), and making it global so I
   can view it's attributes through Firebug, I was able to locate the
   form element on the ajax response. It was the index-5 element for your
   test page. My sample code below. Though this still doesn't help as to
   why we can't reference it using #test2, maybe someone else can get
   something more out of it.

   I've also tried appended the response to the page and still no go.

   --

   var globalHTML;  // global variable

   $(document).ready(function() {

           $.ajax({
                   url: 'http://www.puc.edu/dev/tests/linking-test',
                   type: 'GET',
                   success: function(html) {
                           var $html = $(html);  // wrap response as jquery 
   object

                           globalHTML = $html;  // check object with firebug

                           alert( $html.get(5).action );
                   }
           });

   });

   Using Firebug and looking at the attributes of the object I've found
   that the form is on the 5th-index of the object, for your test page.
   Though this still doesn't really help much

   alert( $(html).get(5).action );

   On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

Ok, my test now reflects your suggestions.  But, sadly, none of that
helped, it is still returning undefined. :(

On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

 Hey Nic,

 I have a couple small recommendations- hopefully one will fix the 
 issue.

 Try using $.get() instead of $.ajax, and specify type option as 
 html-
 alternatively, you can use $.load() if your ultimate purpose is to 
 inject
 this HTML into DOM.

 In addition rather than using find(), just select by ID as a subset 
 of the
 DOM node..

 alert($(html).find(#test) becomes
 alert($(#test, html));

 Hope some of this helps... cheers!

 Nic Luciano
 Senior Web Developer @ 
 AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

 On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com 
 wrote:

  Nope, that does not work either.

  On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
   Maybe try:

   success: function(html){
     alert($(html).find('form').attr('action'));

   I had some issues in the past using form id's with the jquery form
   plugin, but usually getting it using 'form' worked.

   That said, since the response isn't in the DOM yet, I'm not sure 
   if that
   might present an issue (too/instead).

   - Jack

   Nic Hubbard wrote:
Yes, this is very odd. I have tried it quite a few ways, but I 
can
never target the form.  Any other ideas?

It is frustrating because I really need to target a form in the 
html
response...

On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

That's strange. I can't get it to work either and I'm getting 
the same
results as you (I can get #test2, but not #test). I've even 
truncated
the response down to as if you're only receiving the form 
part and
it still doesn't work. I'd be interested in seeing what 
happens here
too.

On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

Test page to show the 
problem:http://www.puc.edu/dev/tests/ajax-test

On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

I am pulling my hair out over this.  I swear that this is a 
bug.

For some reason, I CANNOT target any forms within the html 
response.
I have tried very simple examples and it still won't work.  
Here is
what I have, that still returns undefined:

HTML:
form id=test action=http://test.com;
span id=test2this is my text/span
/form

jQuery:
success: function(html){
  alert($(html).find(#test).attr('action'));
  alert($(html).find(#test2).text());

}

#test2 works, but #test never does, and it seems this is 
because it
  is
a form.  Have I done something wrong here?  Can I not target 
a form?

On Apr 12, 4:35 pm, Nic Hubbard nnhubb...@gmail.com wrote:

I have 

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Ryan


In that case you would need to add something like

html = 'div'+html+'/div';

to your function. Its a bit of an ugly hack I know.

Having played with it a bit now. I think your probably right about it
being a jquery bug. It might be worthwhile exploring which function
the problem lies with then submitting it to the jquery team.

R



On Apr 13, 10:55 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 Hey, that actually worked!  But, why would this have helped?  And, is
 there a way around this, since the real form that I need to get, I
 cannot wrap a div around.

 On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:

  If you wrap your form in a div I think it should work - haven't tested
  it

  R

  On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   Could this be a jQuery bug?

   On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

I still haven't figured it out, but playing around and setting the
ajax response as a jquery object, $(html), and making it global so I
can view it's attributes through Firebug, I was able to locate the
form element on the ajax response. It was the index-5 element for your
test page. My sample code below. Though this still doesn't help as to
why we can't reference it using #test2, maybe someone else can get
something more out of it.

I've also tried appended the response to the page and still no go.

--

var globalHTML;  // global variable

$(document).ready(function() {

        $.ajax({
                url: 'http://www.puc.edu/dev/tests/linking-test',
                type: 'GET',
                success: function(html) {
                        var $html = $(html);  // wrap response as 
jquery object

                        globalHTML = $html;  // check object with 
firebug

                        alert( $html.get(5).action );
                }
        });

});

Using Firebug and looking at the attributes of the object I've found
that the form is on the 5th-index of the object, for your test page.
Though this still doesn't really help much

alert( $(html).get(5).action );

On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

 Ok, my test now reflects your suggestions.  But, sadly, none of that
 helped, it is still returning undefined. :(

 On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

  Hey Nic,

  I have a couple small recommendations- hopefully one will fix the 
  issue.

  Try using $.get() instead of $.ajax, and specify type option as 
  html-
  alternatively, you can use $.load() if your ultimate purpose is to 
  inject
  this HTML into DOM.

  In addition rather than using find(), just select by ID as a subset 
  of the
  DOM node..

  alert($(html).find(#test) becomes
  alert($(#test, html));

  Hope some of this helps... cheers!

  Nic Luciano
  Senior Web Developer @ 
  AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

  On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard nnhubb...@gmail.com 
  wrote:

   Nope, that does not work either.

   On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
Maybe try:

success: function(html){
  alert($(html).find('form').attr('action'));

I had some issues in the past using form id's with the jquery 
form
plugin, but usually getting it using 'form' worked.

That said, since the response isn't in the DOM yet, I'm not 
sure if that
might present an issue (too/instead).

- Jack

Nic Hubbard wrote:
 Yes, this is very odd. I have tried it quite a few ways, but 
 I can
 never target the form.  Any other ideas?

 It is frustrating because I really need to target a form in 
 the html
 response...

 On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

 That's strange. I can't get it to work either and I'm 
 getting the same
 results as you (I can get #test2, but not #test). I've even 
 truncated
 the response down to as if you're only receiving the form 
 part and
 it still doesn't work. I'd be interested in seeing what 
 happens here
 too.

 On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com wrote:

 Test page to show the 
 problem:http://www.puc.edu/dev/tests/ajax-test

 On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com wrote:

 I am pulling my hair out over this.  I swear that this is 
 a bug.

 For some reason, I CANNOT target any forms within the html 
 response.
 I have tried very simple examples and it still won't work. 
  Here is
 what I have, that still returns undefined:

 HTML:
 form 

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

Yeah, but my page returns a full HTML page, so I need to do something
like:

$(body).wrapInner('div/div');

Which, does not seem to work.

On Apr 13, 3:14 pm, Ryan ryank...@gmail.com wrote:
 In that case you would need to add something like

 html = 'div'+html+'/div';

 to your function. Its a bit of an ugly hack I know.

 Having played with it a bit now. I think your probably right about it
 being a jquery bug. It might be worthwhile exploring which function
 the problem lies with then submitting it to the jquery team.

 R

 On Apr 13, 10:55 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  Hey, that actually worked!  But, why would this have helped?  And, is
  there a way around this, since the real form that I need to get, I
  cannot wrap a div around.

  On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:

   If you wrap your form in a div I think it should work - haven't tested
   it

   R

   On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

Could this be a jQuery bug?

On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

 I still haven't figured it out, but playing around and setting the
 ajax response as a jquery object, $(html), and making it global so I
 can view it's attributes through Firebug, I was able to locate the
 form element on the ajax response. It was the index-5 element for your
 test page. My sample code below. Though this still doesn't help as to
 why we can't reference it using #test2, maybe someone else can get
 something more out of it.

 I've also tried appended the response to the page and still no go.

 --

 var globalHTML;  // global variable

 $(document).ready(function() {

         $.ajax({
                 url: 'http://www.puc.edu/dev/tests/linking-test',
                 type: 'GET',
                 success: function(html) {
                         var $html = $(html);  // wrap response as 
 jquery object

                         globalHTML = $html;  // check object with 
 firebug

                         alert( $html.get(5).action );
                 }
         });

 });

 Using Firebug and looking at the attributes of the object I've found
 that the form is on the 5th-index of the object, for your test page.
 Though this still doesn't really help much

 alert( $(html).get(5).action );

 On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

  Ok, my test now reflects your suggestions.  But, sadly, none of that
  helped, it is still returning undefined. :(

  On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

   Hey Nic,

   I have a couple small recommendations- hopefully one will fix the 
   issue.

   Try using $.get() instead of $.ajax, and specify type option as 
   html-
   alternatively, you can use $.load() if your ultimate purpose is 
   to inject
   this HTML into DOM.

   In addition rather than using find(), just select by ID as a 
   subset of the
   DOM node..

   alert($(html).find(#test) becomes
   alert($(#test, html));

   Hope some of this helps... cheers!

   Nic Luciano
   Senior Web Developer @ 
   AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

   On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard 
   nnhubb...@gmail.com wrote:

Nope, that does not work either.

On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
 Maybe try:

 success: function(html){
   alert($(html).find('form').attr('action'));

 I had some issues in the past using form id's with the jquery 
 form
 plugin, but usually getting it using 'form' worked.

 That said, since the response isn't in the DOM yet, I'm not 
 sure if that
 might present an issue (too/instead).

 - Jack

 Nic Hubbard wrote:
  Yes, this is very odd. I have tried it quite a few ways, 
  but I can
  never target the form.  Any other ideas?

  It is frustrating because I really need to target a form in 
  the html
  response...

  On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

  That's strange. I can't get it to work either and I'm 
  getting the same
  results as you (I can get #test2, but not #test). I've 
  even truncated
  the response down to as if you're only receiving the 
  form part and
  it still doesn't work. I'd be interested in seeing what 
  happens here
  too.

  On Apr 13, 6:47 am, Nic Hubbard nnhubb...@gmail.com 
  wrote:

  Test page to show the 
  problem:http://www.puc.edu/dev/tests/ajax-test

  On Apr 13, 9:33 am, Nic Hubbard nnhubb...@gmail.com 
  wrote:

  I am pulling my hair 

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Ryan

In my tests wrapping your full test html page in the div seems to
work. Not pretty but works.




On Apr 13, 11:29 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 Yeah, but my page returns a full HTML page, so I need to do something
 like:

 $(body).wrapInner('div/div');

 Which, does not seem to work.

 On Apr 13, 3:14 pm, Ryan ryank...@gmail.com wrote:

  In that case you would need to add something like

  html = 'div'+html+'/div';

  to your function. Its a bit of an ugly hack I know.

  Having played with it a bit now. I think your probably right about it
  being a jquery bug. It might be worthwhile exploring which function
  the problem lies with then submitting it to the jquery team.

  R

  On Apr 13, 10:55 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   Hey, that actually worked!  But, why would this have helped?  And, is
   there a way around this, since the real form that I need to get, I
   cannot wrap a div around.

   On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:

If you wrap your form in a div I think it should work - haven't tested
it

R

On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

 Could this be a jQuery bug?

 On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

  I still haven't figured it out, but playing around and setting the
  ajax response as a jquery object, $(html), and making it global so I
  can view it's attributes through Firebug, I was able to locate the
  form element on the ajax response. It was the index-5 element for 
  your
  test page. My sample code below. Though this still doesn't help as 
  to
  why we can't reference it using #test2, maybe someone else can get
  something more out of it.

  I've also tried appended the response to the page and still no go.

  --

  var globalHTML;  // global variable

  $(document).ready(function() {

          $.ajax({
                  url: 'http://www.puc.edu/dev/tests/linking-test',
                  type: 'GET',
                  success: function(html) {
                          var $html = $(html);  // wrap response as 
  jquery object

                          globalHTML = $html;  // check object with 
  firebug

                          alert( $html.get(5).action );
                  }
          });

  });

  Using Firebug and looking at the attributes of the object I've found
  that the form is on the 5th-index of the object, for your test page.
  Though this still doesn't really help much

  alert( $(html).get(5).action );

  On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

   Ok, my test now reflects your suggestions.  But, sadly, none of 
   that
   helped, it is still returning undefined. :(

   On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

Hey Nic,

I have a couple small recommendations- hopefully one will fix 
the issue.

Try using $.get() instead of $.ajax, and specify type option 
as html-
alternatively, you can use $.load() if your ultimate purpose is 
to inject
this HTML into DOM.

In addition rather than using find(), just select by ID as a 
subset of the
DOM node..

alert($(html).find(#test) becomes
alert($(#test, html));

Hope some of this helps... cheers!

Nic Luciano
Senior Web Developer @ 
AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard 
nnhubb...@gmail.com wrote:

 Nope, that does not work either.

 On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
  Maybe try:

  success: function(html){
    alert($(html).find('form').attr('action'));

  I had some issues in the past using form id's with the 
  jquery form
  plugin, but usually getting it using 'form' worked.

  That said, since the response isn't in the DOM yet, I'm not 
  sure if that
  might present an issue (too/instead).

  - Jack

  Nic Hubbard wrote:
   Yes, this is very odd. I have tried it quite a few ways, 
   but I can
   never target the form.  Any other ideas?

   It is frustrating because I really need to target a form 
   in the html
   response...

   On Apr 13, 11:45 am, James james.gp@gmail.com wrote:

   That's strange. I can't get it to work either and I'm 
   getting the same
   results as you (I can get #test2, but not #test). I've 
   even truncated
   the response down to as if you're only receiving the 
   form part and
   it still doesn't work. I'd be interested in seeing what 
   happens here
   too.

  

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Nic Hubbard

You are right, that did work.  Thanks, I really appreciate your help
on this!

Had you run into this issue before?

On Apr 13, 3:33 pm, Ryan ryank...@gmail.com wrote:
 In my tests wrapping your full test html page in the div seems to
 work. Not pretty but works.

 On Apr 13, 11:29 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  Yeah, but my page returns a full HTML page, so I need to do something
  like:

  $(body).wrapInner('div/div');

  Which, does not seem to work.

  On Apr 13, 3:14 pm, Ryan ryank...@gmail.com wrote:

   In that case you would need to add something like

   html = 'div'+html+'/div';

   to your function. Its a bit of an ugly hack I know.

   Having played with it a bit now. I think your probably right about it
   being a jquery bug. It might be worthwhile exploring which function
   the problem lies with then submitting it to the jquery team.

   R

   On Apr 13, 10:55 pm, Nic Hubbard nnhubb...@gmail.com wrote:

Hey, that actually worked!  But, why would this have helped?  And, is
there a way around this, since the real form that I need to get, I
cannot wrap a div around.

On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:

 If you wrap your form in a div I think it should work - haven't tested
 it

 R

 On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

  Could this be a jQuery bug?

  On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

   I still haven't figured it out, but playing around and setting the
   ajax response as a jquery object, $(html), and making it global 
   so I
   can view it's attributes through Firebug, I was able to locate the
   form element on the ajax response. It was the index-5 element for 
   your
   test page. My sample code below. Though this still doesn't help 
   as to
   why we can't reference it using #test2, maybe someone else can get
   something more out of it.

   I've also tried appended the response to the page and still no go.

   --

   var globalHTML;  // global variable

   $(document).ready(function() {

           $.ajax({
                   url: 'http://www.puc.edu/dev/tests/linking-test',
                   type: 'GET',
                   success: function(html) {
                           var $html = $(html);  // wrap response as 
   jquery object

                           globalHTML = $html;  // check object with 
   firebug

                           alert( $html.get(5).action );
                   }
           });

   });

   Using Firebug and looking at the attributes of the object I've 
   found
   that the form is on the 5th-index of the object, for your test 
   page.
   Though this still doesn't really help much

   alert( $(html).get(5).action );

   On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

Ok, my test now reflects your suggestions.  But, sadly, none of 
that
helped, it is still returning undefined. :(

On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

 Hey Nic,

 I have a couple small recommendations- hopefully one will fix 
 the issue.

 Try using $.get() instead of $.ajax, and specify type 
 option as html-
 alternatively, you can use $.load() if your ultimate purpose 
 is to inject
 this HTML into DOM.

 In addition rather than using find(), just select by ID as a 
 subset of the
 DOM node..

 alert($(html).find(#test) becomes
 alert($(#test, html));

 Hope some of this helps... cheers!

 Nic Luciano
 Senior Web Developer @ 
 AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

 On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard 
 nnhubb...@gmail.com wrote:

  Nope, that does not work either.

  On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com wrote:
   Maybe try:

   success: function(html){
     alert($(html).find('form').attr('action'));

   I had some issues in the past using form id's with the 
   jquery form
   plugin, but usually getting it using 'form' worked.

   That said, since the response isn't in the DOM yet, I'm 
   not sure if that
   might present an issue (too/instead).

   - Jack

   Nic Hubbard wrote:
Yes, this is very odd. I have tried it quite a few 
ways, but I can
never target the form.  Any other ideas?

It is frustrating because I really need to target a 
form in the html
response...

On Apr 13, 11:45 am, James james.gp@gmail.com 
wrote:

That's strange. I can't get it to work either and I'm 
getting 

[jQuery] Re: Finding ID within Ajax response

2009-04-13 Thread Ryan


Glad I could help. I haven't seen this problem before even though it
does seem like quite a common thing to need to do.

I think with a bit more work you could come up with a more elegant
work around such as using the append/prepend function in conjunction
with say the body and /body tags. Although whatever you use will
be a bit of a hack and at the end of the day as long as you get the
data you need thats all that matters.

Cheers R






On Apr 13, 11:39 pm, Nic Hubbard nnhubb...@gmail.com wrote:
 You are right, that did work.  Thanks, I really appreciate your help
 on this!

 Had you run into this issue before?

 On Apr 13, 3:33 pm, Ryan ryank...@gmail.com wrote:

  In my tests wrapping your full test html page in the div seems to
  work. Not pretty but works.

  On Apr 13, 11:29 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   Yeah, but my page returns a full HTML page, so I need to do something
   like:

   $(body).wrapInner('div/div');

   Which, does not seem to work.

   On Apr 13, 3:14 pm, Ryan ryank...@gmail.com wrote:

In that case you would need to add something like

html = 'div'+html+'/div';

to your function. Its a bit of an ugly hack I know.

Having played with it a bit now. I think your probably right about it
being a jquery bug. It might be worthwhile exploring which function
the problem lies with then submitting it to the jquery team.

R

On Apr 13, 10:55 pm, Nic Hubbard nnhubb...@gmail.com wrote:

 Hey, that actually worked!  But, why would this have helped?  And, is
 there a way around this, since the real form that I need to get, I
 cannot wrap a div around.

 On Apr 13, 2:46 pm, Ryan ryank...@gmail.com wrote:

  If you wrap your form in a div I think it should work - haven't 
  tested
  it

  R

  On Apr 13, 10:22 pm, Nic Hubbard nnhubb...@gmail.com wrote:

   Could this be a jQuery bug?

   On Apr 13, 2:13 pm, James james.gp@gmail.com wrote:

I still haven't figured it out, but playing around and setting 
the
ajax response as a jquery object, $(html), and making it global 
so I
can view it's attributes through Firebug, I was able to locate 
the
form element on the ajax response. It was the index-5 element 
for your
test page. My sample code below. Though this still doesn't help 
as to
why we can't reference it using #test2, maybe someone else can 
get
something more out of it.

I've also tried appended the response to the page and still no 
go.

--

var globalHTML;  // global variable

$(document).ready(function() {

        $.ajax({
                url: 
'http://www.puc.edu/dev/tests/linking-test',
                type: 'GET',
                success: function(html) {
                        var $html = $(html);  // wrap response 
as jquery object

                        globalHTML = $html;  // check object 
with firebug

                        alert( $html.get(5).action );
                }
        });

});

Using Firebug and looking at the attributes of the object I've 
found
that the form is on the 5th-index of the object, for your test 
page.
Though this still doesn't really help much

alert( $(html).get(5).action );

On Apr 13, 10:28 am, Nic Hubbard nnhubb...@gmail.com wrote:

 Ok, my test now reflects your suggestions.  But, sadly, none 
 of that
 helped, it is still returning undefined. :(

 On Apr 13, 1:03 pm, Nic Luciano adaptive...@gmail.com wrote:

  Hey Nic,

  I have a couple small recommendations- hopefully one will 
  fix the issue.

  Try using $.get() instead of $.ajax, and specify type 
  option as html-
  alternatively, you can use $.load() if your ultimate 
  purpose is to inject
  this HTML into DOM.

  In addition rather than using find(), just select by ID as 
  a subset of the
  DOM node..

  alert($(html).find(#test) becomes
  alert($(#test, html));

  Hope some of this helps... cheers!

  Nic Luciano
  Senior Web Developer @ 
  AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano

  On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard 
  nnhubb...@gmail.com wrote:

   Nope, that does not work either.

   On Apr 13, 12:20 pm, Jack Killpatrick j...@ihwy.com 
   wrote:
Maybe try:

success: function(html){
  alert($(html).find('form').attr('action'));

I had some issues in the past using form id's with the 
jquery form
plugin, but 

[jQuery] Re: Finding id and setting as variable

2008-11-07 Thread MorningZ

but this doesn't work.

Care to elaborate?do you get an error?  unexpected results?
something else?


On Nov 7, 7:19 am, Liam Potter [EMAIL PROTECTED] wrote:
 Hi guys, this should be a quick one

 I have a div, which has a unqiue id (pulled from the database) so
 something like this.

 div class=msg id=msg%#Eval(PrimaryKeyID)%
 /div

 and I'm trying to get the id number from it like this

 var uid = $(.msg).id.replace('msg', );

 as I'm running a similar function

 $(span.yes).click(function (event) {
             event.preventDefault();
             var inc = this.id.replace('yes', );

 });

 I thought I could just replace the this for a selector but this doesn't
 work.

 Can anyone let me know how I would do this.

 Thanks,
 Liam


[jQuery] Re: Finding id and setting as variable

2008-11-07 Thread Liam Potter


ok, this has stopped the error, but it was only returning the id of the 
first div.msg it found, I changed it to this


var uid = $(span#yes+ 
inc).parent().parent().parent().attr(id).replace('msg', );


which is now working.

Thanks for the help guys.

Richard D. Worth wrote:

Change

$(.msg).id

to

$(.msg).attr(id)

- Richard

On Fri, Nov 7, 2008 at 7:27 AM, Liam Potter [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:



The error I get in firebug is

$(.msg).id is undefined

basically what I'm trying to do is pass this into an ajax post to
delete the message, so it's vital the id is the same one from the
database.


MorningZ wrote:

but this doesn't work.

Care to elaborate?do you get an error?  unexpected results?
something else?


On Nov 7, 7:19 am, Liam Potter [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
 


Hi guys, this should be a quick one

I have a div, which has a unqiue id (pulled from the
database) so
something like this.

div class=msg id=msg%#Eval(PrimaryKeyID)%
/div

and I'm trying to get the id number from it like this

var uid = $(.msg).id.replace('msg', );

as I'm running a similar function

$(span.yes).click(function (event) {
   event.preventDefault();
   var inc = this.id.replace('yes', );

});

I thought I could just replace the this for a selector but
this doesn't
work.

Can anyone let me know how I would do this.

Thanks,
Liam
   








[jQuery] Re: Finding id and setting as variable

2008-11-07 Thread Richard D. Worth
Change

$(.msg).id

to

$(.msg).attr(id)

- Richard

On Fri, Nov 7, 2008 at 7:27 AM, Liam Potter [EMAIL PROTECTED] wrote:


 The error I get in firebug is

 $(.msg).id is undefined

 basically what I'm trying to do is pass this into an ajax post to delete
 the message, so it's vital the id is the same one from the database.


 MorningZ wrote:

 but this doesn't work.

 Care to elaborate?do you get an error?  unexpected results?
 something else?


 On Nov 7, 7:19 am, Liam Potter [EMAIL PROTECTED] wrote:


 Hi guys, this should be a quick one

 I have a div, which has a unqiue id (pulled from the database) so
 something like this.

 div class=msg id=msg%#Eval(PrimaryKeyID)%
 /div

 and I'm trying to get the id number from it like this

 var uid = $(.msg).id.replace('msg', );

 as I'm running a similar function

 $(span.yes).click(function (event) {
event.preventDefault();
var inc = this.id.replace('yes', );

 });

 I thought I could just replace the this for a selector but this doesn't
 work.

 Can anyone let me know how I would do this.

 Thanks,
 Liam






[jQuery] Re: Finding id and setting as variable

2008-11-07 Thread Liam Potter


The error I get in firebug is

$(.msg).id is undefined

basically what I'm trying to do is pass this into an ajax post to delete 
the message, so it's vital the id is the same one from the database.


MorningZ wrote:

but this doesn't work.

Care to elaborate?do you get an error?  unexpected results?
something else?


On Nov 7, 7:19 am, Liam Potter [EMAIL PROTECTED] wrote:
  

Hi guys, this should be a quick one

I have a div, which has a unqiue id (pulled from the database) so
something like this.

div class=msg id=msg%#Eval(PrimaryKeyID)%
/div

and I'm trying to get the id number from it like this

var uid = $(.msg).id.replace('msg', );

as I'm running a similar function

$(span.yes).click(function (event) {
event.preventDefault();
var inc = this.id.replace('yes', );

});

I thought I could just replace the this for a selector but this doesn't
work.

Can anyone let me know how I would do this.

Thanks,
Liam





[jQuery] Re: Finding id of this

2007-04-24 Thread Shelane

In terms of searching a scope  I'm not quite sure if this is true:

there are many divs with a class of newsitem.  I want to bind a
click event to all p.newsheaders within all the newsitems divs.  So,
this repeats for each story:

div class=newsitem
   p class=newsheaderMy News Header/p
   div class=newscontentContent will be loaded here/div
/div
the next news story will be the same format.

Can I do this?:


$(function(){
   $('p.newsheader', '.newsitem').click(function(){



});


On Apr 20, 10:38 am, Brandon Aaron [EMAIL PROTECTED] wrote:
 You can use the jQuery method attr() to get the id attribute of the element.

 $(this).attr('id');

 However, since 'this' is the element and there is a DOM property
 exposing the id you can get the id from the a tag like this.

 this.id;

 So with that knowledge here is how the click hander would look.

 $(function(){
$(this).find('a.reminder').click(function(){
$('#div_' + this.id).toggle();
this.blur()
return false;
});//end click

 });

 I also just used the DOM method blur instead of the jQuery blur()
 method (which actually just calls the DOM method blur()). Since you
 have the DOM element and not doing anything else with it, it makes
 more sense to just use the DOM method. Saving on typing too. :)

 You can also write your selector like this:

 $('a.reminder', this).click(function() {

 The second parameter is the scope in which jQuery should run the selector.

 --
 Brandon Aaron

 On 4/20/07,ShelaneEnos [EMAIL PROTECTED] wrote:



  I apologize if this solution is posted, but I searched and trying to get
  through hundreds of results is a bit painful.

  So I have these titles: Create Reminder, Create Hold Status, Change State.
  I want to bind a click event to all of them which will toggle the show/hide
  attribute of a corresponding div.

  So I have this:

  $(function(){
  $(this).find('a.reminder').click(function(){
  $(this).toggle();
  $(this).blur();
  return false;
  });//end click
  });

  However, in this function I'm toggling the title link itself, which is NOT
  what I want.  I want to toggle the corresponding div.  so, the titles look
  like this in html:

  a href=# class=reminder id=areminderCreate Reminder/a

  I would like to use the id (areminder) in this case to now toggle the div
  div_areminder.  How do I find the id of each of these a tags to apply
  toggle like this:

  find id method
  $('#div_' + idofatag).toggle();

  ??

  That's my question.  That you very much.  Have a nice day.



[jQuery] Re: Finding id of this

2007-04-24 Thread Shelane

Sorry, hit the button and the message posted prematurely.

Can I do this?:

$(function(){
   $('p.newsheader', '.newsitem').click(function(){
   var myid = $(this).attr('id');
   $(this).next().load('mynews.lasso?news=' + id);
   });
});




On Apr 24, 8:03 pm, Shelane [EMAIL PROTECTED] wrote:
 In terms of searching a scope  I'm not quite sure if this is true:

 there are many divs with a class of newsitem.  I want to bind a
 click event to all p.newsheaders within all the newsitems divs.  So,
 this repeats for each story:

 div class=newsitem
p class=newsheaderMy News Header/p
div class=newscontentContent will be loaded here/div
 /div
 the next news story will be the same format.

 Can I do this?:

 $(function(){
$('p.newsheader', '.newsitem').click(function(){

 });

 On Apr 20, 10:38 am, Brandon Aaron [EMAIL PROTECTED] wrote:

  You can use the jQuery method attr() to get the id attribute of the element.

  $(this).attr('id');

  However, since 'this' is the element and there is a DOM property
  exposing the id you can get the id from the a tag like this.

  this.id;

  So with that knowledge here is how the click hander would look.

  $(function(){
 $(this).find('a.reminder').click(function(){
 $('#div_' + this.id).toggle();
 this.blur()
 return false;
 });//end click

  });

  I also just used the DOM method blur instead of the jQuery blur()
  method (which actually just calls the DOM method blur()). Since you
  have the DOM element and not doing anything else with it, it makes
  more sense to just use the DOM method. Saving on typing too. :)

  You can also write your selector like this:

  $('a.reminder', this).click(function() {

  The second parameter is the scope in which jQuery should run the selector.

  --
  Brandon Aaron

  On 4/20/07,ShelaneEnos [EMAIL PROTECTED] wrote:

   I apologize if this solution is posted, but I searched and trying to get
   through hundreds of results is a bit painful.

   So I have these titles: Create Reminder, Create Hold Status, Change State.
   I want to bind a click event to all of them which will toggle the 
   show/hide
   attribute of a corresponding div.

   So I have this:

   $(function(){
   $(this).find('a.reminder').click(function(){
   $(this).toggle();
   $(this).blur();
   return false;
   });//end click
   });

   However, in this function I'm toggling the title link itself, which is NOT
   what I want.  I want to toggle the corresponding div.  so, the titles look
   like this in html:

   a href=# class=reminder id=areminderCreate Reminder/a

   I would like to use the id (areminder) in this case to now toggle the 
   div
   div_areminder.  How do I find the id of each of these a tags to apply
   toggle like this:

   find id method
   $('#div_' + idofatag).toggle();

   ??

   That's my question.  That you very much.  Have a nice day.



[jQuery] Re: Finding id of this

2007-04-24 Thread Ⓙⓐⓚⓔ

change
 $('p.newsheader', '.newsitem').click(function(){
to
 $('p.newsheader , .newsitem').click(function(){




On 4/24/07, Shelane [EMAIL PROTECTED] wrote:



Sorry, hit the button and the message posted prematurely.

Can I do this?:

$(function(){
   $('p.newsheader', '.newsitem').click(function(){
   var myid = $(this).attr('id');
   $(this).next().load('mynews.lasso?news=' + id);
   });
});




On Apr 24, 8:03 pm, Shelane [EMAIL PROTECTED] wrote:
 In terms of searching a scope  I'm not quite sure if this is true:

 there are many divs with a class of newsitem.  I want to bind a
 click event to all p.newsheaders within all the newsitems divs.  So,
 this repeats for each story:

 div class=newsitem
p class=newsheaderMy News Header/p
div class=newscontentContent will be loaded here/div
 /div
 the next news story will be the same format.

 Can I do this?:

 $(function(){
$('p.newsheader', '.newsitem').click(function(){

 });

 On Apr 20, 10:38 am, Brandon Aaron [EMAIL PROTECTED] wrote:

  You can use the jQuery method attr() to get the id attribute of the
element.

  $(this).attr('id');

  However, since 'this' is the element and there is a DOM property
  exposing the id you can get the id from the a tag like this.

  this.id;

  So with that knowledge here is how the click hander would look.

  $(function(){
 $(this).find('a.reminder').click(function(){
 $('#div_' + this.id).toggle();
 this.blur()
 return false;
 });//end click

  });

  I also just used the DOM method blur instead of the jQuery blur()
  method (which actually just calls the DOM method blur()). Since you
  have the DOM element and not doing anything else with it, it makes
  more sense to just use the DOM method. Saving on typing too. :)

  You can also write your selector like this:

  $('a.reminder', this).click(function() {

  The second parameter is the scope in which jQuery should run the
selector.

  --
  Brandon Aaron

  On 4/20/07,ShelaneEnos [EMAIL PROTECTED] wrote:

   I apologize if this solution is posted, but I searched and trying to
get
   through hundreds of results is a bit painful.

   So I have these titles: Create Reminder, Create Hold Status, Change
State.
   I want to bind a click event to all of them which will toggle the
show/hide
   attribute of a corresponding div.

   So I have this:

   $(function(){
   $(this).find('a.reminder').click(function(){
   $(this).toggle();
   $(this).blur();
   return false;
   });//end click
   });

   However, in this function I'm toggling the title link itself, which
is NOT
   what I want.  I want to toggle the corresponding div.  so, the
titles look
   like this in html:

   a href=# class=reminder id=areminderCreate Reminder/a

   I would like to use the id (areminder) in this case to now toggle
the div
   div_areminder.  How do I find the id of each of these a tags to
apply
   toggle like this:

   find id method
   $('#div_' + idofatag).toggle();

   ??

   That's my question.  That you very much.  Have a nice day.





--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: Finding id of this

2007-04-24 Thread Shelane Enos
Wouldn’t that apply the click to the newsitem div and the p.newsheader and
not just the p.newsheader inside each div.newsitem ?

I was thinking scope of “within” this (whatever I say this is) context.  If
there are multiple items that fix the scope, will it be applied for each of
those items. 

On 4/24/07 8:36 PM, ?ⓐⓚⓔ [EMAIL PROTECTED] wrote:

 change
$('p.newsheader', '.newsitem').click(function(){
 to
$('p.newsheader , .newsitem').click(function(){
 
 
 
 
 On 4/24/07, Shelane [EMAIL PROTECTED]  mailto:[EMAIL PROTECTED]  wrote:
 
 Sorry, hit the button and the message posted prematurely.
 
 Can I do this?: 
 
 $(function(){
$('p.newsheader', '.newsitem').click(function(){
var myid = $(this).attr('id');
$(this).next().load('mynews.lasso?news=' + id);
});
 });
 
 
 
 
 On Apr 24, 8:03 pm, Shelane [EMAIL PROTECTED] wrote:
  In terms of searching a scope  I'm not quite sure if this is true:
 
  there are many divs with a class of newsitem.  I want to bind a
  click event to all p.newsheaders within all the newsitems divs.  So,
  this repeats for each story:
 
  div class=newsitem
 p class=newsheaderMy News Header/p
 div class=newscontentContent will be loaded here/div
  /div
  the next news story will be the same format.
 
  Can I do this?:
 
  $(function(){
 $('p.newsheader', '.newsitem').click(function(){
 
  });
 
  On Apr 20, 10:38 am, Brandon Aaron [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]  wrote:
 
   You can use the jQuery method attr() to get the id attribute of the
 element.
 
   $(this).attr('id');
 
   However, since 'this' is the element and there is a DOM property
   exposing the id you can get the id from the a tag like this.
 
   this.id http://this.id ;
 
   So with that knowledge here is how the click hander would look.
 
   $(function(){
  $(this).find('a.reminder').click(function(){
  $('#div_' + this.id http://this.id ).toggle();
  this.blur()
  return false;
  });//end click
 
   });
 
   I also just used the DOM method blur instead of the jQuery blur()
   method (which actually just calls the DOM method blur()). Since you
   have the DOM element and not doing anything else with it, it makes
   more sense to just use the DOM method. Saving on typing too. :)
 
   You can also write your selector like this:
 
   $('a.reminder', this).click(function() {
 
   The second parameter is the scope in which jQuery should run the
 selector.
 
   --
   Brandon Aaron
 
   On 4/20/07,ShelaneEnos [EMAIL PROTECTED] wrote:
 
I apologize if this solution is posted, but I searched and trying to
get
through hundreds of results is a bit painful.
 
So I have these titles: Create Reminder, Create Hold Status, Change
 State.
I want to bind a click event to all of them which will toggle the
 show/hide
attribute of a corresponding div.
 
So I have this:
 
$(function(){
$(this).find('a.reminder').click(function(){
$(this).toggle();
$(this).blur();
return false;
});//end click
});
 
However, in this function I'm toggling the title link itself, which
 is NOT
what I want.  I want to toggle the corresponding div.  so, the
 titles look 
like this in html:
 
a href=# class=reminder id=areminderCreate Reminder/a
 
I would like to use the id (areminder) in this case to now toggle
 the div 
div_areminder.  How do I find the id of each of these a tags to
apply
toggle like this:
 
find id method
$('#div_' + idofatag).toggle();
 
??
 
That's my question.  That you very much.  Have a nice day.
 
 
 




[jQuery] Re: Finding id of this

2007-04-24 Thread Ⓙⓐⓚⓔ

Yes it would! if you want to set the context it has to be a dom element or a
jQuery object.
try
  $('p.newsheader', $('.newsitem')).click(function(){

but aren't all the .newsheaders in a .newsitem?

Maybe I'm missing something!

On 4/24/07, Shelane Enos [EMAIL PROTECTED] wrote:


 Wouldn't that apply the click to the newsitem div and the p.newsheaderand not 
just the
p.newsheader inside each div.newsitem ?

I was thinking scope of within this (whatever I say this is) context.
 If there are multiple items that fix the scope, will it be applied for each
of those items.

On 4/24/07 8:36 PM, ?ⓐⓚⓔ [EMAIL PROTECTED] wrote:

change
   $('p.newsheader', '.newsitem').click(function(){
to
   $('p.newsheader , .newsitem').click(function(){




On 4/24/07, *Shelane* [EMAIL PROTECTED]  mailto:[EMAIL PROTECTED][EMAIL 
PROTECTED] wrote:


Sorry, hit the button and the message posted prematurely.

Can I do this?:

$(function(){
   $('p.newsheader', '.newsitem').click(function(){
   var myid = $(this).attr('id');
   $(this).next().load('mynews.lasso?news=' + id);
   });
});




On Apr 24, 8:03 pm, Shelane [EMAIL PROTECTED] wrote:
 In terms of searching a scope  I'm not quite sure if this is true:

 there are many divs with a class of newsitem.  I want to bind a
 click event to all p.newsheaders within all the newsitems divs.  So,
 this repeats for each story:

 div class=newsitem
p class=newsheaderMy News Header/p
div class=newscontentContent will be loaded here/div
 /div
 the next news story will be the same format.

 Can I do this?:

 $(function(){
$('p.newsheader', '.newsitem').click(function(){

 });

 On Apr 20, 10:38 am, Brandon Aaron [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]  wrote:

  You can use the jQuery method attr() to get the id attribute of the
element.

  $(this).attr('id');

  However, since 'this' is the element and there is a DOM property
  exposing the id you can get the id from the a tag like this.

  this.id http://this.id http://this.id ;

  So with that knowledge here is how the click hander would look.

  $(function(){
 $(this).find('a.reminder').click(function(){
 $('#div_' + this.id http://this.id http://this.id).toggle();
 this.blur()
 return false;
 });//end click

  });

  I also just used the DOM method blur instead of the jQuery blur()
  method (which actually just calls the DOM method blur()). Since you
  have the DOM element and not doing anything else with it, it makes
  more sense to just use the DOM method. Saving on typing too. :)

  You can also write your selector like this:

  $('a.reminder', this).click(function() {

  The second parameter is the scope in which jQuery should run the
selector.

  --
  Brandon Aaron

  On 4/20/07,ShelaneEnos [EMAIL PROTECTED] wrote:

   I apologize if this solution is posted, but I searched and trying to
get
   through hundreds of results is a bit painful.

   So I have these titles: Create Reminder, Create Hold Status, Change
State.
   I want to bind a click event to all of them which will toggle the
show/hide
   attribute of a corresponding div.

   So I have this:

   $(function(){
   $(this).find('a.reminder').click(function(){
   $(this).toggle();
   $(this).blur();
   return false;
   });//end click
   });

   However, in this function I'm toggling the title link itself, which
is NOT
   what I want.  I want to toggle the corresponding div.  so, the
titles look
   like this in html:

   a href=# class=reminder id=areminderCreate Reminder/a

   I would like to use the id (areminder) in this case to now toggle
the div
   div_areminder.  How do I find the id of each of these a tags to
apply
   toggle like this:

   find id method
   $('#div_' + idofatag).toggle();

   ??

   That's my question.  That you very much.  Have a nice day.








--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ


[jQuery] Re: Finding id of this

2007-04-20 Thread Shelane

Nevermind.  I answered my own question.  Duh, I've used .attr before.
Here are my changes which work beautifully.  Thanks again jQuery for
easy unobtrusive js.

New function:

$(function(){
$(this).find('a.reminder').click(function(){
var myid = $(this).attr('id');
$('#div_' + myid).toggle();
$(this).blur();
return false;
});
});


On Apr 20, 10:21 am, Shelane Enos [EMAIL PROTECTED] wrote:
 I apologize if this solution is posted, but I searched and trying to get
 through hundreds of results is a bit painful.

 So I have these titles: Create Reminder, Create Hold Status, Change State.
 I want to bind a click event to all of them which will toggle the show/hide
 attribute of a corresponding div.

 So I have this:

 $(function(){
 $(this).find('a.reminder').click(function(){
 $(this).toggle();
 $(this).blur();
 return false;
 });//end click

 });

 However, in this function I'm toggling the title link itself, which is NOT
 what I want.  I want to toggle the corresponding div.  so, the titles look
 like this in html:

 a href=# class=reminder id=areminderCreate Reminder/a

 I would like to use the id (areminder) in this case to now toggle the div
 div_areminder.  How do I find the id of each of these a tags to apply
 toggle like this:

 find id method
 $('#div_' + idofatag).toggle();

 ??

 That's my question.  That you very much.  Have a nice day.



[jQuery] Re: Finding id of this

2007-04-20 Thread Karl Swedberg

Hi Shelane,

I think this should work...

$(function(){
$('a.reminder').click(function(){
var divId = '#div_' + $(this).attr('id');
$(divId).toggle();
$(this).blur();
return false;
});//end click
});

Let me know if it doesn't produce the results you're looking for.

Cheers,

--Karl
_
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Apr 20, 2007, at 1:21 PM, Shelane Enos wrote:



I apologize if this solution is posted, but I searched and trying  
to get

through hundreds of results is a bit painful.

So I have these titles: Create Reminder, Create Hold Status, Change  
State.
I want to bind a click event to all of them which will toggle the  
show/hide

attribute of a corresponding div.

So I have this:

$(function(){
$(this).find('a.reminder').click(function(){
$(this).toggle();
$(this).blur();
return false;
});//end click
});

However, in this function I'm toggling the title link itself, which  
is NOT
what I want.  I want to toggle the corresponding div.  so, the  
titles look

like this in html:

a href=# class=reminder id=areminderCreate Reminder/a

I would like to use the id (areminder) in this case to now toggle  
the div
div_areminder.  How do I find the id of each of these a tags to  
apply

toggle like this:

find id method
$('#div_' + idofatag).toggle();

??

That's my question.  That you very much.  Have a nice day.





[jQuery] Re: Finding id of this

2007-04-20 Thread Brandon Aaron


You can use the jQuery method attr() to get the id attribute of the element.

$(this).attr('id');

However, since 'this' is the element and there is a DOM property
exposing the id you can get the id from the a tag like this.

this.id;

So with that knowledge here is how the click hander would look.

$(function(){
  $(this).find('a.reminder').click(function(){
  $('#div_' + this.id).toggle();
  this.blur()
  return false;
  });//end click
});

I also just used the DOM method blur instead of the jQuery blur()
method (which actually just calls the DOM method blur()). Since you
have the DOM element and not doing anything else with it, it makes
more sense to just use the DOM method. Saving on typing too. :)

You can also write your selector like this:

$('a.reminder', this).click(function() {

The second parameter is the scope in which jQuery should run the selector.

--
Brandon Aaron


On 4/20/07, Shelane Enos [EMAIL PROTECTED] wrote:


I apologize if this solution is posted, but I searched and trying to get
through hundreds of results is a bit painful.

So I have these titles: Create Reminder, Create Hold Status, Change State.
I want to bind a click event to all of them which will toggle the show/hide
attribute of a corresponding div.

So I have this:

$(function(){
$(this).find('a.reminder').click(function(){
$(this).toggle();
$(this).blur();
return false;
});//end click
});

However, in this function I'm toggling the title link itself, which is NOT
what I want.  I want to toggle the corresponding div.  so, the titles look
like this in html:

a href=# class=reminder id=areminderCreate Reminder/a

I would like to use the id (areminder) in this case to now toggle the div
div_areminder.  How do I find the id of each of these a tags to apply
toggle like this:

find id method
$('#div_' + idofatag).toggle();

??

That's my question.  That you very much.  Have a nice day.