Solved

Remove jquery tag

Posted on 2009-06-27
4
376 Views
Last Modified: 2012-05-07
Hi,

I have a script that adds tabs (ui/tabs plugin) but I don't have a way to remove them intuitivly. The problem is they are all ajax tabs so I cannot somehow put a button inside them that will call the remove function. Or can I?

How can I let the user click and close an ajax tab from within the tab?

Thank you!!!!!
0
Comment
Question by:webspirit
  • 2
  • 2
4 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24731552
If the tabset has id="tabs", try something like this:
<button onclick="$('#tabs').tabs('remove',$('#tabs').tabs('option', 'selected'));">Remove</button>

Open in new window

0
 

Author Comment

by:webspirit
ID: 24731901
Thank you.

How can I put it inside the tab since in loads the content by ajax?
An idea would be to pass the tabid to the remote page, which it will insert the code into the output. That would require redesigning both the links and the code for the remote page. Is there some more elegant way? Could I somehow run code after the tab has loaed and inject the code in there?

Thank you!!
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 500 total points
ID: 24732254
You could define a load handler and use the append() method to add the button to the loaded tab:
$('#tabs').tabs({ 

  load:function(event,ui) {

    $(ui.panel).append(

    "<button onclick=\"$('#tabs').tabs('remove',$('#tabs').tabs('option', 'selected'));\">Remove</button>");

  }

});

Open in new window

0
 

Author Closing Comment

by:webspirit
ID: 31597623
Just what I needed! Thank you very much!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now