javascript - Stuck reloading ajax content in a jQuery Tab programatically - Stack Overflow
I'm very new to programming so please forgive me my noobness. I'm using the excellent jQuery tabs for my application, I load external content into the tabs via ajax, and in one of those tabs I need to programatically reload the content of that tab fter a result. I've followed the documentation* to no avail.
I have initialized the tabs in my root page very simply with:
Javascript:
$(document).ready(function(){
$("#tabs").tabs({ cookie: { expires: 30 } });
});
The HTML:
<div id="tabs">
<ul>
<li><a href="#moderatorManage"><span>Find and Manage Moderators</span></a></li>
<li><a href="flaggedCards/" id="flaggedCards" ><span>Flagged Cards</span></a></li>
<li><a href="pendingDelete/"><span>SinBin / Pending Delete</span></a></li>
</ul>
</div>
You can see I load an external URL of "flaggedCards/" In there I have more jQuery with this function:
$(document).ready(function(){
$("#controls_{{id}} input").click(function() {
$(this).parent().parent().parent().addClass("highlight").fadeTo("slow", 0.1);
$("#tabs").tabs( 'load' , 0 ); // fails also tried various selectors
});
});
What I am trying to do, is call the flaggedCards tab to reload when that function is called, I've tried various different syntaxes to no avail.
- docs.jquery/UI/API/1.7.1/Tabs#method-load
I'm very new to programming so please forgive me my noobness. I'm using the excellent jQuery tabs for my application, I load external content into the tabs via ajax, and in one of those tabs I need to programatically reload the content of that tab fter a result. I've followed the documentation* to no avail.
I have initialized the tabs in my root page very simply with:
Javascript:
$(document).ready(function(){
$("#tabs").tabs({ cookie: { expires: 30 } });
});
The HTML:
<div id="tabs">
<ul>
<li><a href="#moderatorManage"><span>Find and Manage Moderators</span></a></li>
<li><a href="flaggedCards/" id="flaggedCards" ><span>Flagged Cards</span></a></li>
<li><a href="pendingDelete/"><span>SinBin / Pending Delete</span></a></li>
</ul>
</div>
You can see I load an external URL of "flaggedCards/" In there I have more jQuery with this function:
$(document).ready(function(){
$("#controls_{{id}} input").click(function() {
$(this).parent().parent().parent().addClass("highlight").fadeTo("slow", 0.1);
$("#tabs").tabs( 'load' , 0 ); // fails also tried various selectors
});
});
What I am trying to do, is call the flaggedCards tab to reload when that function is called, I've tried various different syntaxes to no avail.
- docs.jquery./UI/API/1.7.1/Tabs#method-load
3 Answers
Reset to default 4I was able to duplicate the exact same issue that you report in your post. This is how I ended up solving it.
In the root page hosting the tabs, add this function:
function selectTab(index){
$("#tabs").tabs('load', index);
}
Then in your external Url page "flaggedCards/", replace the line that says:
$("#tabs").tabs( 'load' , 0 );
with this:
selectTab(0);
I don't know why this workaround does the trick. Perhaps it is a bug.
To get the script executed, you have to make sure the ajax requests's data type is "html" - see $.ajax options. To do this, try the tabs ajaxOptions option when setting up your tabs.
$("#tabs").tabs({ cookie: { expires: 30 }, ajaxOptions: {dataType: "html"} });
The other issue might be that the $(document).ready(function(){
probably isn't firing when the tab content is being loaded via ajax. Try removing that and the corresponding }
. When it's loading your content via ajax, hopefully it's inserted it in the document before it evals the scripts.
I'm out of ideas. Hope that helps :-)
i should mention that it is running the scripts in the html it loads, see the addclass function, that runs fine, however after running that it doesnt reload the tab with the code i have entered. i will try adding that datatype however.
- 在沉默中炸裂爆发!2013安卓系统大事记
- 2012年NEC云时代平台软件全国巡展启动
- spi - Interrupt safety of `HAL_SPI_TransmitReceive` - Stack Overflow
- Formulas in Looker Studio with Hubspot data not working - Stack Overflow
- typescript - Command 'pod install' failed, Cause: binbash -c - Stack Overflow
- reactjs - how to fetch headers in middleware in Next js - Stack Overflow
- java - Bluej throws SSLHandshakeException making http request - Stack Overflow
- How to programmatically trigger "Next desktop background" in Windows using C#? - Stack Overflow
- rcpp - C++ AVX2 custom functions (e.g., "exp") not working on Windows (but work on Linux) - Stack Overflow
- Power query performance (SOAP connector) very low on migrating from Excel to Power BI Desktop - Stack Overflow
- android - startActivity() on external application not bring it foreground in task of testing external application - Stack Overfl
- reactjs - NextAuth cookie not being sent when I use the development server, but being sent when I use HoppscotchBrowser to send
- c# - Make custom file property columns show by default in Windows File Explorer - Stack Overflow
- javascript - Why does the iterator close after a break in a for...of loop? - Stack Overflow
- javascript - onPointerOver and onPointerOut detect all child elements - Stack Overflow
- Make property of python class dependent on external variable? - Stack Overflow
- Cannot open DocumentPicker window in React Native app, Android platform - Stack Overflow