AJAX loaded anchors problem
I load content to div using ajax. In that new loaded content are anchors which make another ajax requests, but they don't work. I suppose that it's caused by $(document).ready();
For example:
- $(document).ready(function(){
- $('.dokosika').click(function(){
- kod = $(this).attr('id');
- pridajDoKosika(kod);
- return false;
- });
- function pridajDoKosika(kod){
- $.getJSON("/ajax/dokosika/"+kod,function(data){
- obnovKosik(data.suma+",-",data.pocet);
- });
- }
- function obnovKosik(suma,pocet){
- $("#kosik .loader").fadeIn('fast');
- $('#kosik .cena').fadeOut('slow');
- $('#kosik .pocet-polozek').fadeOut('slow');
- setTimeout(function(){
- $('#kosik .cena').text(suma).fadeIn('slow');
- $('#kosik .pocet-polozek').text(pocet).fadeIn('slow');
- $("#kosik .loader").fadeOut('slow');
- }, 500);
- }
- <table class="zoznam">
- <thead>
- <tr>
- <th>
- Name
- </th>
- <th>
- Type
- </th>
- <th>
- Length
- </th>
- <th>
- Count
- </th>
- <th>
- Price
- </th>
- <th>
- </th>
- </tr>
- </thead>
- <tbody>
- <tr class="riadok-c-0" id="PLU001N1">
- <td class="tucne tmavomodre">
- Dummy item
- </td>
- <td>
- New licence
- </td>
- <td>
- 1 year
- </td>
- <td>
- <input type="text" value="1" /> licence
- </td>
- <td class="tucne doprava cena">
- 1249,-
- </td>
- <td class="tucne tmavomodre">
- <a href="">refresh</a> | <a class="smazat" rel="0" href="">remove</a>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- </tr>
- <tr class="sucet">
- <td class="doprava" colspan="6">
- Price including VAT: <span class="suma">1498.8,-</span>
- </td>
- </tr>
- </tbody>
- </table>
Anchor with class '.dokosika' in loaded content doesn't work as I want to .. What solve my problem ?