Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Remove jquery tag

Posted on 2009-06-27
4
Medium Priority
?
414 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
Suggested Courses

722 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