[jQuery] Re: binding after .get()

2009-04-28 Thread hphoeksma

Hi...

well the docs says:

Currently not supported: ..., change, ...

And that's what I need ;-)

Henjo

On Apr 17, 9:02 pm, Andy Matthews li...@commadelimited.com wrote:
 If you're using a current version of jQuery, then the liveQuery method is
 for you.

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

   _  

 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
 Behalf Of Karl Swedberg
 Sent: Friday, April 17, 2009 1:51 PM
 To: jquery-en@googlegroups.com
 Subject: [jQuery] Re: binding after .get()

 On Apr 16, 2009, at 11:27 AM, hphoeksma wrote:

 Hi Donny,

 thanks for your reply. This will lead to lots of extra code I guess...
 Would there be another way?

 See the FAQ for more information:

 http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st...
 ing_after_an_AJAX_request.3F

 --Karl

 
 Karl Swedbergwww.englishrules.comwww.learningjquery.com


[jQuery] Re: binding after .get()

2009-04-17 Thread Karl Swedberg



On Apr 16, 2009, at 11:27 AM, hphoeksma wrote:



Hi Donny,

thanks for your reply. This will lead to lots of extra code I guess...
Would there be another way?



See the FAQ for more information:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: binding after .get()

2009-04-17 Thread Andy Matthews
If you're using a current version of jQuery, then the liveQuery method is
for you.
 
http://docs.jquery.com/Events/live#typefn
 

  _  

From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Karl Swedberg
Sent: Friday, April 17, 2009 1:51 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: binding after .get()




On Apr 16, 2009, at 11:27 AM, hphoeksma wrote:



Hi Donny,

thanks for your reply. This will lead to lots of extra code I guess...
Would there be another way?


See the FAQ for more information:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_work
ing_after_an_AJAX_request.3F


--Karl


Karl Swedberg
www.englishrules.com
www.learningjquery.com



[jQuery] Re: binding after .get()

2009-04-16 Thread Donny Kurnia

hphoeksma wrote:
 Hi all,
 
 new to jQuery I am having difficulty on the binding concept.
 
 Currently using this function to regenerate a full form based on a PHP
 script.
 
 --
 $(select).change(function () {
 $.get('script.php', {'c': c, 'sc': sc }, function(data) {
 $('form').html(data);
 });
 return false;
 })
 .change();
 --
 This works, but I'd like to use some next steps in the newly created
 selectors.
 
 I understand I need to (re)bind these selectors, but am lost on how to
 achieve that. Anyone?
 
 Thanks in advance,
 
 Henjo

This is what work for me:
1. I write all the js code near the element that need it. In your case,
I will write the jquery code soon after the /select tag.

The code will be like this:

select 
   ...
/select
script type=text/javascript
jquery(function($){
  $(select).change(function(){

  });
});
/script

2. When I do ajax that will replace the current DOM element, I will also
 send the code for the new element in the XMLHttpRequest response.
In your case above, the script.php will return data to .get like this:

.
select 
   ...
/select
script type=text/javascript
jquery(function($){
  $(select).change(function(){

  });
});
/script
..


With this approach, the injected data will bring all the needed code for
it's element. I use this for form, list with pagination, and all other
XMLHttpRequest.

Writing js code near element that need it, beside maintain the
unobtrusive, also made debugging it easier.

I hope this will work with your case.

--
Donny Kurnia
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia



[jQuery] Re: binding after .get()

2009-04-16 Thread hphoeksma

Hi Donny,

thanks for your reply. This will lead to lots of extra code I guess...
Would there be another way?

Thanks!

Henjo

On Apr 16, 5:14 pm, Donny Kurnia donnykur...@gmail.com wrote:
 hphoeksma wrote:
  Hi all,

  new to jQuery I am having difficulty on the binding concept.

  Currently using this function to regenerate a full form based on a PHP
  script.

  --
  $(select).change(function () {
          $.get('script.php', {'c': c, 'sc': sc }, function(data) {
              $('form').html(data);
          });
          return false;
      })
      .change();
  --
  This works, but I'd like to use some next steps in the newly created
  selectors.

  I understand I need to (re)bind these selectors, but am lost on how to
  achieve that. Anyone?

  Thanks in advance,

  Henjo

 This is what work for me:
 1. I write all the js code near the element that need it. In your case,
 I will write the jquery code soon after the /select tag.

 The code will be like this:

 select 
    ...
 /select
 script type=text/javascript
 jquery(function($){
   $(select).change(function(){
     
   });});

 /script

 2. When I do ajax that will replace the current DOM element, I will also
  send the code for the new element in the XMLHttpRequest response.
 In your case above, the script.php will return data to .get like this:

 .
 select 
    ...
 /select
 script type=text/javascript
 jquery(function($){
   $(select).change(function(){
     
   });});

 /script
 ..

 With this approach, the injected data will bring all the needed code for
 it's element. I use this for form, list with pagination, and all other
 XMLHttpRequest.

 Writing js code near element that need it, beside maintain the
 unobtrusive, also made debugging it easier.

 I hope this will work with your case.

 --
 Donny Kurniahttp://hantulab.blogspot.comhttp://www.plurk.com/user/donnykurnia


[jQuery] Re: binding after .get()

2009-04-16 Thread Donny Kurnia

hphoeksma wrote:
 Hi Donny,
 
 thanks for your reply. This will lead to lots of extra code I guess...
 Would there be another way?
 
 Thanks!
 
 Henjo

What important is re-bind all code to new element that loaded throught
ajax request. One way to do it is put the needed js code in the returned
response, so it's get inserted and executed with the new elements.

The step 1 in my solution is my practice. If it lead to a lot code
rewriting, don't do it for all element, but to the element that got
returned from ajax request.


 On Apr 16, 5:14 pm, Donny Kurnia donnykur...@gmail.com wrote:
 hphoeksma wrote:
 Hi all,
 new to jQuery I am having difficulty on the binding concept.
 Currently using this function to regenerate a full form based on a PHP
 script.
 --
 $(select).change(function () {
 $.get('script.php', {'c': c, 'sc': sc }, function(data) {
 $('form').html(data);
 });
 return false;
 })
 .change();
 --
 This works, but I'd like to use some next steps in the newly created
 selectors.
 I understand I need to (re)bind these selectors, but am lost on how to
 achieve that. Anyone?
 Thanks in advance,
 Henjo
 This is what work for me:
 1. I write all the js code near the element that need it. In your case,
 I will write the jquery code soon after the /select tag.

 The code will be like this:

 select 
...
 /select
 script type=text/javascript
 jquery(function($){
   $(select).change(function(){
 
   });});

 /script

 2. When I do ajax that will replace the current DOM element, I will also
  send the code for the new element in the XMLHttpRequest response.
 In your case above, the script.php will return data to .get like this:

 .
 select 
...
 /select
 script type=text/javascript
 jquery(function($){
   $(select).change(function(){
 
   });});

 /script
 ..

 With this approach, the injected data will bring all the needed code for
 it's element. I use this for form, list with pagination, and all other
 XMLHttpRequest.

 Writing js code near element that need it, beside maintain the
 unobtrusive, also made debugging it easier.

 I hope this will work with your case.

 --
 Donny Kurniahttp://hantulab.blogspot.comhttp://www.plurk.com/user/donnykurnia
 

--
Donny Kurnia
http://hantulab.blogspot.com
http://www.plurk.com/user/donnykurnia