3

I try to get .live content into a div when there is a keyup... I looked at the forumtopic here but I didn't find the answer...

Why does my code not works? I use this JQuery:

<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js"></script> 


<script type="text/javascript">

$(document).ready(function() {
// When the document is ready set up our sortable with it's inherant function(s)

  $(".atleetnaamlink").live('keyup', function(){
    alert('test');
  });  
</script>
  • $(selector).live(events, data, handler); // jQuery 1.3+ $(document).delegate(selector, events, data, handler); // jQuery 1.4.3+ $(document).on(events, selector, data, handler); // jQuery 1.7+ – Pragnesh Chauhan Nov 10 '12 at 09:30

4 Answers4

3

try on

$(selector).live(events, data, handler);                // jQuery 1.3+
$(document).delegate(selector, events, data, handler);  // jQuery 1.4.3+
$(document).on(events, selector, data, handler);        // jQuery 1.7+

$(document).ready(function() {
 $("body").on('keyup' ,'.atleetnaamlink', function(){
   alert('test');
 });  
});

DEMO

Pragnesh Chauhan
  • 8,363
  • 9
  • 42
  • 53
  • Thanks! Now it works with ==> jsfiddle.net/oli4tje/4Ksur/2 But now I want to get a change on change OR keyup. What needs a change? And I want load a content of another page when keyup (or change) from .naam in the div .naamid! Normally I work with .get jquery. Can I do this agian? – Olivier Peeters Nov 10 '12 at 10:34
1

.live() is deprecated. Use .on() instead. That will work.

$(".atleetnaamlink").on('keyup', function(){
    alert('test');
}); 
techfoobar
  • 65,616
  • 14
  • 114
  • 135
  • Thanks! Now it works with ==> http://jsfiddle.net/oli4tje/4Ksur/2/ But now I want to get a change on change OR keyup. What needs a change? And I want load a content of another page when keyup (or change) from .naam in the div .naamid! Normally I work with .get jquery. Can I do this agian? – Olivier Peeters Nov 10 '12 at 10:22
1

You are missing }); and Working demo http://jsfiddle.net/JwRRH/

Hope it helps :) by the way live is deprecated and if you keen check this out What's wrong with the jQuery live method?

code

  $(document).ready(function() {
    // When the document is ready set up our sortable with it's inherant function(s)

      $(".atleetnaamlink").live('keyup', function(){
        alert('test');
      });  
    });​

or*

 $(document).ready(function() {
        // When the document is ready set up our sortable with it's inherant function(s)

          $(document).live('keyup',".atleetnaamlink", function(){
            alert('test');
          });  
        });​
Community
  • 1
  • 1
Tats_innit
  • 33,991
  • 10
  • 71
  • 77
  • @OlivierPeeters cool man no probs rest above should help. See the working demo attached http://jsfiddle.net/JwRRH/ `:)` – Tats_innit Nov 10 '12 at 09:34
  • Thanks! Now it works with ==> jsfiddle.net/oli4tje/4Ksur/2 But now I want to get a change on change OR keyup. What needs a change? And I want load a content of another page when keyup (or change) from .naam in the div .naamid! Normally I work with .get jquery. Can I do this agian? – Olivier Peeters Nov 10 '12 at 10:26
  • Yes I know but I get 2 message when I type a letter? – Olivier Peeters Nov 10 '12 at 11:30
  • @OlivierPeeters weird I get only one alert, Anyhoo look in here http://stackoverflow.com/questions/8576475/why-does-this-jquery-event-run-twice :) – Tats_innit Nov 10 '12 at 11:47
0

Add this above:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
<script type="text/javascript" src="jquery-ui-1.7.1.custom.min.js"></script> 

and see if this works.

and important thing not to forget to accept it if it solves your issue.

Jai
  • 74,255
  • 12
  • 74
  • 103