Skip to main content
added 86 characters in body
Source Link
Robert Lindgren
  • 24.5k
  • 12
  • 55
  • 79

Thank you all for your answers and help. With help of Ahmed Zia's comments I found solution to my problem. As the complete ulul is getting formed dynamically, and the page is unable to find the click event later. So I changed my code like below so that the click event will be registered after the ulul got created and bound to div (tabsContainerDiv_idtabsContainerDiv_id) of a page

$(document).ready(function(){ ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js"); function getItems() { //Get list items and onSuccess bind to ul registerEvents(); } function registerEvents(){ $('#tabsContainerDiv_id').on('click',' ul.tabs li', function(){ // Switch between tabs }); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js");

function getItems() {
//Get list items and onSuccess bind to ul

registerEvents();
}

function registerEvents(){
    $('#tabsContainerDiv_id').on('click',' ul.tabs li', function(){  
        // Switch between tabs
    });
}
});
</script>
});

Thank you all for your answers and help. With help of Ahmed Zia's comments I found solution to my problem. As the complete ul is getting formed dynamically, and the page is unable to find the click event later. So I changed my code like below so that the click event will be registered after the ul got created and bound to div (tabsContainerDiv_id) of a page

$(document).ready(function(){ ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js"); function getItems() { //Get list items and onSuccess bind to ul registerEvents(); } function registerEvents(){ $('#tabsContainerDiv_id').on('click',' ul.tabs li', function(){ // Switch between tabs }); } });

Thank you all for your answers and help. With help of Ahmed Zia's comments I found solution to my problem. As the complete ul is getting formed dynamically, and the page is unable to find the click event later. So I changed my code like below so that the click event will be registered after the ul got created and bound to div (tabsContainerDiv_id) of a page

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){

ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js");

function getItems() {
//Get list items and onSuccess bind to ul

registerEvents();
}

function registerEvents(){
    $('#tabsContainerDiv_id').on('click',' ul.tabs li', function(){  
        // Switch between tabs
    });
}
});
</script>
Source Link
Ahmed
  • 91
  • 1
  • 6

Thank you all for your answers and help. With help of Ahmed Zia's comments I found solution to my problem. As the complete ul is getting formed dynamically, and the page is unable to find the click event later. So I changed my code like below so that the click event will be registered after the ul got created and bound to div (tabsContainerDiv_id) of a page

$(document).ready(function(){ ExecuteOrDelayUntilScriptLoaded(getItems, "sp.js"); function getItems() { //Get list items and onSuccess bind to ul registerEvents(); } function registerEvents(){ $('#tabsContainerDiv_id').on('click',' ul.tabs li', function(){ // Switch between tabs }); } });