[jQuery] Re: Problem with creating dynamic html...

2009-01-12 Thread Kean

in 1.3 it will be something like this

$(),live('click', function(){

});


or you can do something like this in 1.2.6

$().click(function(e){
  e = e.target || e.srcElement;

  if $(e).is('CSS selector')
 fire the function

});

adding some bubbling

$().click(function(e){
  e =e.target || e.srcElement;
  obj = e;
  ancestors = [];

  while(obj) {
ancestors.push(obj);
obj = obj.parentNode;
  }

  if $(ancestors).is('CSS selector')
 fire the function
});

still needs a lot of work but should be a starting point. Good luck.

On Jan 12, 4:13 am, Nedim  wrote:
> Thank you.
> I will check it later.
>
> On Jan 11, 3:01 pm, Mike Alsup  wrote:
>
> > > This is in html (by default)
>
> > >       
> > >       
> > >          
> > >              
> > >                Kolicina Naslov
>
> > >                 
> > >                     
> > >                     
> > >                          > > name="vrijednosti[][1][kol]" type="text" title="Količina npr. 100ml,
> > > 10 kom i sl." /> 
> > >                          > > name="vrijednosti[][1][naziv]" type="text" title="Primjer: U polje
> > > količina unesete 10 kom, a u naslov jaja."  />
> > >                          
> > >                     
> > >                 
>
> > >                         Dodaj sastojak > > span>
> > >              
> > >        
>
> > >    
> > >        Nova grupa
>
> > > When i click on "grupanovi" it creates:
>
> > > $('#grupanovi').append(' > > id="grupa'+document.getElementById('brojacgrupa').value+'"
> > > class="grupa"> > > class="naslov-pos">Kolicina Naslov > > span> > > class="dodani-sastojci"> > > type="text" title="Količina npr. 100ml, 10 kom i sl." />  > > class="dodani-sastojci"> > > type="text" title="Primjer: U polje količina unesete 10 kom, a u
> > > naslov jaja."  /> > > div>Dodaj sastojak > > div>');
>
> > > But this works only on default:
>
> > >  $(".novisastojak").click(function(){
> > >           alert('testiram');
>
> > >          });
>
> > > not on dynamical content created.
>
> > > Help?
>
> > >           });
>
> > Here's two resources you should read:
>
> >http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st...
>
> >http://www.learningjquery.com/2008/03/working-with-events-part-1
>
> > Note that with the soon-to-be-released 1.3 version of jQuery this
> > situation will be much easier to handle.
>
> > Mike


[jQuery] Re: Problem with creating dynamic html...

2009-01-12 Thread Nedim

Thank you.
I will check it later.

On Jan 11, 3:01 pm, Mike Alsup  wrote:
> > This is in html (by default)
>
> >       
> >       
> >          
> >              
> >                Kolicina Naslov
>
> >                 
> >                     
> >                     
> >                          > name="vrijednosti[][1][kol]" type="text" title="Količina npr. 100ml,
> > 10 kom i sl." /> 
> >                          > name="vrijednosti[][1][naziv]" type="text" title="Primjer: U polje
> > količina unesete 10 kom, a u naslov jaja."  />
> >                          
> >                     
> >                 
>
> >                         Dodaj sastojak > span>
> >              
> >        
>
> >    
> >        Nova grupa
>
> > When i click on "grupanovi" it creates:
>
> > $('#grupanovi').append(' > id="grupa'+document.getElementById('brojacgrupa').value+'"
> > class="grupa"> > class="naslov-pos">Kolicina Naslov > span> > class="dodani-sastojci"> > type="text" title="Količina npr. 100ml, 10 kom i sl." />  > class="dodani-sastojci"> > type="text" title="Primjer: U polje količina unesete 10 kom, a u
> > naslov jaja."  /> > div>Dodaj sastojak > div>');
>
> > But this works only on default:
>
> >  $(".novisastojak").click(function(){
> >           alert('testiram');
>
> >          });
>
> > not on dynamical content created.
>
> > Help?
>
> >           });
>
> Here's two resources you should read:
>
> http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st...
>
> http://www.learningjquery.com/2008/03/working-with-events-part-1
>
> Note that with the soon-to-be-released 1.3 version of jQuery this
> situation will be much easier to handle.
>
> Mike


[jQuery] Re: Problem with creating dynamic html...

2009-01-11 Thread Mike Alsup

> This is in html (by default)
>
>       
>       
>          
>              
>                Kolicina Naslov
>
>                 
>                     
>                     
>                          name="vrijednosti[][1][kol]" type="text" title="Količina npr. 100ml,
> 10 kom i sl." /> 
>                          name="vrijednosti[][1][naziv]" type="text" title="Primjer: U polje
> količina unesete 10 kom, a u naslov jaja."  />
>                          
>                     
>                 
>
>                         Dodaj sastojak span>
>              
>        
>
>    
>        Nova grupa
>
> When i click on "grupanovi" it creates:
>
> $('#grupanovi').append(' id="grupa'+document.getElementById('brojacgrupa').value+'"
> class="grupa"> class="naslov-pos">Kolicina Naslov span> class="dodani-sastojci"> type="text" title="Količina npr. 100ml, 10 kom i sl." />  class="dodani-sastojci"> type="text" title="Primjer: U polje količina unesete 10 kom, a u
> naslov jaja."  /> div>Dodaj sastojak div>');
>
> But this works only on default:
>
>  $(".novisastojak").click(function(){
>           alert('testiram');
>
>          });
>
> not on dynamical content created.
>
> Help?
>
>           });


Here's two resources you should read:

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

http://www.learningjquery.com/2008/03/working-with-events-part-1

Note that with the soon-to-be-released 1.3 version of jQuery this
situation will be much easier to handle.

Mike