0

I tried running my javascript code which is declarete in same file with ajax loadContent function. My problem is, after loading content, that function do not work.

I looked for solution, and i found .live() method in jQuery but I'm using 1.9 version which not support that now.

Here im loading spreadsheet to html doc:

var spreadsheet = $( 'div#item-list table > tbody' );

function loadContent(){
     $.post( 'ajaxRequest.php', { 'function' : 'loadData' } )
      .done( function( content ){
               spreadsheet.empty().append( content );
      });
    }

In this same file i have this code: Before i loaded action buttons into spreadsheet, and now i would like do some action with form like "removerow"

$('input[name="removerow"]').on( "click" , function (){
            $.post( 'ajaxRequest.php', { 'function' : 'removerow', 'ID' : ID } )
          .done( function( result ){
                  alert(result);
          });
            return false;
        });

Problem is in javascript, not PHP, I'm sure that on 100%.

Thanks in advance!

1 Answer 1

2

You're looking for the delegated version of on() :

$('#item-list').on('click', 'input[name="removerow"]', function (){
   ...
});
Sign up to request clarification or add additional context in comments.

1 Comment

It's working! :) Do you have other solution to loading content, other method to do ? :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.