Last active
March 23, 2017 05:21
-
-
Save ppbntl19/7008984ec7bcb89a2d9e9a38bb1df6ad to your computer and use it in GitHub Desktop.
Using Javascript MutationObserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//More Details https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver | |
//Will not work if more then one lookup is used on same page | |
//Please remove all comments for live | |
//Add Mututationobserver on selected component | |
$("#component-abca-2a71-4474").on("click",".search_for_salesforce_record,.lookup_salesforce_record ", function() { | |
new MutationObserver(function(mutations) { | |
// Do something here | |
if($('#component-abca-2a71-4474 .found_record_list li') && $('#component-abca-2a71-4474 .found_record_list li').length > 0) { | |
//Add css to change for lookup result | |
$('#component-abca-2a71-4474 .found_record_list li').append('<span class="glyphicon glyphicon-hand-up"></span><style>#select_icon{display:none}.found_record_list #select_icon{display:inline}</style>'); | |
// Stop observing if needed: | |
this.disconnect(); | |
} | |
if($('#component-abca-2a71-4474 .found_record_list').text()=='No records found'){ | |
//Add css to change for Default message | |
$('#component-abca-2a71-4474 .found_record_list').text('Please try Again ... :)'); | |
// Stop observing if needed: | |
this.disconnect(); | |
} | |
// Stop observing if needed: | |
this.disconnect(); | |
}).observe(document.querySelector('#component-abca-2a71-4474 .found_record_list'), {childList: true}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment