Пытаюсь удалить существующие вкладки, которые были добавлены динамическиJquery

Программирование на jquery
Ответить Пред. темаСлед. тема
Гость
 Пытаюсь удалить существующие вкладки, которые были добавлены динамически

Сообщение Гость »


Here i am in a situtation where i am trying to add the dynamic tabs to the existing tabs but also if that link or popup is agai opened, i am trying to make sure it does not duplicate the tabs, my current code is doing as such as of now

Here is my html and my jquery code

Код: Выделить всё

function loadbtns(dataAttributes) {   $.ajax({     url: "x.cfm?section=11",     type: 'POST',     data: dataAttributes,     dataType: 'json',           success: function(response) {       console.log(response);       if(Object.keys(response).length > 0) {         $('#tabs').find("li.addedDynamic").each(function() {           $(this).remove();         });         var tabTitle1 = response.title1; // replace with how you access your title in data         var tabContent1 = response.msg1 + "\n" + response.label1 + "\n" + response.textData1 + "\n" + response.content1; // replace with how you access your content in data         var tabTitle2 = response.title2;// replace with how you access your title in data         var tabContent2 = response.msg2 + "\n" + response.label2 + "\n" + response.textData2 + "\n" + response.content2; // replace with how you access your content in data         var tabTemplate = "[*][url=#{href}]#{label}[/url]";         var id1 = "tabs-" + ( $("#tabs li").length + 1 );         var id2 = "tabs-" + ( $("#tabs li").length + 2 );         var li1 = $( tabTemplate.replace( /#\{href\}/g, "#" + id1 ).replace( /#\{label\}/g, tabTitle1 ) );         var li2 = $( tabTemplate.replace( /#\{href\}/g, "#" + id2 ).replace( /#\{label\}/g, tabTitle2 ) );         $("#tabs").find( ".ui-tabs-nav" ).append( li1 );         $("#tabs").append( "" + tabContent1 + "" );         $("#tabs").find( ".ui-tabs-nav" ).append( li2 );         $("#tabs").append( "" + tabContent2 + "" );         $("#tabs").tabs( "refresh" );       }     }   }); } 
now the html code i have is:

Код: Выделить всё

             [list]                 [*][url=#newMgrAprvlScreen][/url]                 [*][url=#commentsSectionData][/url]             [/list]                                                                                                                                                                       
the above will stay as is and will never be changed and deleted, the new tabs will be created by the jquery code and the jquery response is ike this

Код: Выделить всё

{     "textData1": "",     "msg1": " accepted and email sent successfully!",     "textData2": "",     "msg2": "request has been sent!",     "title2": "Request",     "title1": "Accepted",     "content2": "",     "content1": "",     "label2": "Request",     "label1": "Accepted " } 
but it keeps on adding new tabs instead of clearing existing if any, what could be wrong here


Источник: https://stackoverflow.com/questions/781 ... ally-added
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Jquery»