简体   繁体   中英

Is there a way to redirect content loaded with JQuery ui tabs?

I have a situation where the ajax loaded content of a JQuery ui Tab...

http://api.jqueryui.com/tabs/

...needs to have a part of the html that is loaded when a tab is clicked to populate a div in another part of the page.

Note: that the tabs are working fine... I just need to make just one part go somewhere else.

Perhaps something like this... But i can't find in the documentation the object to search.

$(".tabsZ").tabs({
    load: function (event, ui) {
        var mmm = ?????.find("div#messageToShow");
        if (mmm.length != 0) {
            $('#divMessage').html(mmm);
            ?????.html('');
        }
    }
});

????? = the object to search.

Tabs in JQueryUI are just <div> 's on the same page but rendered horizontally. So all you have to do, is poke whatever information you have into your own <div> or <span> somewhere on the same page, even if it's on another tab.

So, in one tab you determine what the new text is (possibly via an onclick handler or whatever):

<div id="sourcediv"> Here's whatever was rendered </div>
...
var newtext = $('#sourcediv').html()

Then you poke it into say targetdiv even when that's on a different tab and clear the contents of your source:

<div id="targetdiv"> This will be overwritten from sourcediv </div>
$('#targetdiv').html(newtext);
$('#sourcediv').html('');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM