javascriptjqueryjqmodal

Hide value in JAVAScript modal pop-up


<select onchange="SUGAR.email2.composeLayout.applyEmailTemplate('0', 
this.options[this.selectedIndex].value);" id="email_template0" name="email_template0">

<option value="">-none-</option>
<option value="159a06ef-4d58-6eff-a969-52fdff05d328">Case Closure</option>
<option value="182641ab-44c0-719d-04b3-52fdffa2b2d2">Case Creation</option>
</select>

I have this java modal pop-up. I would like to hide certain values i.e. 159a06ef-4d58-6eff-a969-52fdff05d328. Incidentally these are drop-down values.

I've tried this but it don't work.

$(document).on('DOMNodeInserted', '#composeHeaderTable0', function(event) {
$("#email_template0 option[value='159a06ef-4d58-6eff-a969-52fdff05d328']").hide();
});

Any pointer please. Thanks in advance.

John


Solution

  • This is the correct method

    $(document).bind('DOMNodeInserted', '#composeHeaderTable0', function(event) {
    

    Instead of this

    $(document).on('DOMNodeInserted', '#composeHeaderTable0', function(event) {
    

    In addition I am also able to hide/show based on other element values like this.

    $(document).bind('DOMNodeInserted', '#composeHeaderTable0', function(event) {
        if ($('#data_parent_type0').val() == 'Leads') {
        $("#email_template0 option[value='159a06ef-4d58-6eff-a969-52fdff05d328']").hide();
        }
    });
    

    Thanks to pointers from Ritesh.