views:

24

answers:

1

In the below code i send a json request for delete_st() on response i need that particular label and the two <br> to be removed.How can this be done

       <script>
   function manage_profiles()
   {
     var html = '<div name="tlist" id="list"><b>Profile</b><br><br>';
    {% for groupid,empname,uid in response_dict.emp_arr%}
     if('{{empid}}' == id)
     {
        html+='<label id={{uid}}>{{empname}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img class=center src="/images/delete.jpg" onclick="javascript:var a=delete_st({{uid}})" /></label><br><br>';
     }
  {% endfor %}
  html += '</div>';
  html+='<input type="hidden" id="update_id" />';
  html+='</div>';
  $dialog.html(html)
  .dialog({
     autoOpen: true,
     position: 'center' ,
     title: 'profile',
     draggable: false,
     width : 550,
     height : 300, 
     resizable : false,
     modal : true,
     buttons: { "Update" : function() { 
     var ret=validate(2,this);return ret;
     },"Cancel" : function() { $(this).dialog("close"); }} 
  });
  $dialog.dialog('open');
  }
A: 

try this:

    <script type="text/javascript">

    function manage_profiles()
    {
        var html = '<div name="tlist" id="list"><b>Profile</b><br><br>';

        {% for groupid,empname,uid in response_dict.emp_arr%}
            if('{{empid}}' == id) {
                html+='<label class="delete-st-reference" id={{uid}}>{{empname}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img class=center src="/images/delete.jpg" /></label><br><br>';
            }
        {% endfor %}
        html += '</div>';
        html += '<input type="hidden" id="update_id" />';
        html += '</div>';

        var delete_st_model = function(ev) {

            ev.stopPropagation();

            var id = $(this).attr('id');

            alert("I'm going to delete this record : " + id );

            $(this).remove();

            return false;

        };

        $dialog.html(html);
        $dialog.find("label.delete-st-reference").bind("click", delete_st_model);

        $dialog.dialog( {
                autoOpen: true,
                position: 'center' ,
                title: 'profile',
                draggable: false,
                width : 550,
                height : 300, 
                resizable : false,
                modal : true,
                buttons: { 
                    "Update" : function() { var ret=validate(2,this);return ret; },
                    "Cancel" : function() { $(this).dialog("close"); }
                } 
            });

        $dialog.dialog('open');
    }
</script>
andres descalzo