Solved

Remove jquery tag

Posted on 2009-06-27
4
389 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fix Form size HTML 16 30
how can i break an array into a couple 5 22
Html using "Or" in condition 3 24
JS to redirect to prev page 8 16
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

685 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