Tuesday, January 15, 2013

Dynamic acordian Jquery


   function replyAccordion(complaintNo) {
            $("#existingCustomersTab").find("#ticketHistorySubTab").find("#complaintNoHidden").val(complaintNo);
            $.ajax({
                url: "CallRegister2.aspx/fetchReply",
                data: "{complaintNo:'" + complaintNo + "'}",
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataFilter: function (data) { return data; },
                success: function (data) {
                    var $div2 = $('<div/>');
                    var $h3 = $('<h3/>');
                    var $div = $('<div/>');
                    var $p = $('<p/>');
                    var $textarea = $('<TextArea/>').attr('id', 'replyTextArea').css('width', '325px');
                    var $select = $('<Select/>').attr('id', 'statusSelect2').append(statusStr);
                    var $select2 = $('<Select/>').attr('id', 'repliedBySelect').append("<option value='Executive'>Executive</option><option value='Customer'>Customer</option>");
                    var $button = $('<Input/>').attr('value', 'Post Reply').attr('type', 'button').attr('id', 'replyButton');
                    $h3.append("Reply Post").append("| ComplaintNo:").append(complaintNo).append("| Status:").append("");
                    $p.append($textarea).append("<br />").append($select2).append($select).append($button);
                    $div.append($p);
                    $div2.append($h3).append($div);
                    $.each(data.d, function (i, item) {
                        var $h3 = $('<h3/>');
                        var $div = $('<div/>');
                        var $p = $('<p/>');
                        $h3.append("Replied By:").append(item.repliedBy).append("| On:").append(item.replyDate).append("| Status:").append(item.ticketStatus);
                        $p.append(item.reply);
                        $div.append($p);
                        $div2.append($h3).append($div);
                    });
                    $div2.accordion({ active: 0, autoHeight: false });
                    $("#existingCustomersTab").find("#ticketHistorySubTab").find("#ticketHistoryAccordion").empty().append($div2);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(textStatus);
                }
            });
        }

No comments:

Post a Comment