Improve company productivity with a Business Account.Sign Up

x
?
Solved

Remove jquery tag

Posted on 2009-06-27
4
Medium Priority
?
441 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 2000 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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

606 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