i have a table with a button which adds some rows to the table and it works fine , i want to load their parent div in the another page via jquery Load function but when i load them the button wont work anymore
here is my html code , actually i just wrote this but you get the idea and also ignore the syntax problems
<head>
<script>
$(function(){
$('#adder').click(function(){
$(this).siblings('table').append('<tr><td></td></tr>');
}
}
</script>
<head>
<body>
<div id="main">
<table> </table>
<a href="" id="adder"> </a>
</div>
</body>
in the another page altho i have the same jquery code in the header but the button doesn’t work anymore
here is my other page
<head>
<script>
function loader(){
$('#loader').load('a.php #main');
}
</script>
</head>
<body>
<div id="loader"></div>
</body>
i tride to ad jq code at the end of div so when it’s loaded in the another page jq get loaded too
<div id="main">
<table> </table>
<a href="" id="adder"> </a>
<script>
$('#adder').click(function(){
$(this).siblings('table').append('<tr><td></td></tr>');
}
</script>
</div>
but still doesn’t work
///////////////////////
another question :
how can i use live when there is no event ?
for example i have a plugin which has some effects on page divs and its called on the page load time
<head>
<script>
$(function(){
$('div').plugin(plugin settings);
})
</script>
</head>
now if i add a div to the page how should i use live so my new div get that effect ?
http://www.alfajango.com/blog/the-difference-between-jquerys-bind-live-and-delegate/
The big “ah ha!” moment for me learning delegates was to simply google for the definition of delegate.
It’s one of those “computer sciency” words that doesn’t make much sense until you’ve mastered the concept or googled the definition. It helps to know the definition before mastering the term. It was named “delegate” for a reason :p
In your example, the newly created elements added by the .load() are sort of these “juveniles” or “adolescents” that are too young to handle the responsibility of events. So when you request an event from them, the browser looks to the delegate in order to learn what should happen.
To add a plugin (your second question) to new DOM elements, you would have to enable the plugin during the load event.