Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7546641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:15:04+00:00 2026-05-30T09:15:04+00:00

i’m not so good at jquery and i’ve got this issue: i’m using jquery

  • 0

i’m not so good at jquery and i’ve got this issue:

i’m using jquery tabs as:

<li><a href="content.php?div=Production">Production</a></li>
<li><a href="content.php?div=Digital">Digital</a></li>

declared as:

$(function() {

    $( "#tabs" ).tabs({
        load: function(event, ui) {
            console.log("load event ran");
            $('a', ui.panel).live("click", function() {
                   $(ui.panel).load(this.href);
                   return false;
                   });
        }
   });
   $("#tabs").bind('tabsshow',function(event, ui) {
    window.location = ui.tab;
})
});

in content i have grid definitions – each tab has it’s own table to load:

switch($div){
            case "Production":
                $tab = '1';
                include('div_master.php');
                break;
            case "Digital":
                $tab = '2';
                include('div_digital.php');
                break;
            default:
                include('div_master.php');
                break;
        }

after above php i’ve got grid object loading db results:

$(function() {
    var grid = $(".grid").loadGrid({ ....});
});

i also store grid object in a variable so i can access sql query so i can export it to excel by pressing a button on a page:

    $('#toexcel').live("click",function() {
        var sql = grid.data().sql;
        $.ajax({
            url: "toExcel.php",
            data: "sql="+encodeURIComponent(sql),
        });
        sql = '';
    });
});

my problem is that when i load fist tab from fresh, export some results to excel, then change to second tab – the button exports the same query from the first tab!
so obviously var sql = grid.data().sql; is not updated with the new data despite grid being reloaded.

first tab always works no matter how many times i change between tabs,
but second works only when page/DOM is completely reloaded.

how do i correct this?


Edit 2 – i have separated grids for both tables – still having the same issue.

i really don’t think that the problem is with reusing the grid object – i think that the problem is with jquery UI – tabs, specifically how the handle reloading DOM.


ADDITION

please see firebug console for requests:
see when freshly loaded – ajax only send 1 request to toExcel, but after switching a tab (div-m – 1st tab, div-d – 2nd tab) it sends 2 requests. and depending on the tab it cancels either 2nd query for fist tab, 1st query for second tab – that’s why 1st tab always working!

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:15:05+00:00Added an answer on May 30, 2026 at 9:15 am

    UPDATED: code stripped to the bone! 😉

    your code should be like this:

    var sql = '';
    $(function() {
        $("#tabs").tabs({
            select: function(event, ui) {
                $(ui.tab.hash).find('table').loadGrid({
                    loadComplete: function() {
                        sql = $(this).data().sql;
                    }
                });
            }
        });
        $('#toexcel').live("click", function() {
            $.ajax({
                url: "toExcel.php",
                data: "sql=" + encodeURIComponent(sql),
            });
        });
    });
    

        <div id="tabs">
            <ul>
                <li><a href="#production">Production</a></li>
                <li><a href="#digital">Digital</a></li>
            </ul>
            <div id="production">
             <table class="production grid" action="content.php?div=Production"></table>
           </div>
            <div id="digital">
             <table class="digital grid" action="content.php?div=Digital"></table>
           </div>
        </div>
    

    Explanation:

    when using jquery-ui tabs, the <a> tag that act as tab is not fired ( jquery prevent it’s click event, cause it is actually used as tab and not as link ), also your html-tabs code will not work as expected ( will not switch tabs ) cause the <a> tag hash ( href="#something" ) should match the id ( id="something" ) of it’s respective container ( in this case div ), instead you have associated to each anchor a direct url-query ( content.php?.. ) that, again, will never be fired and in this case will never switch any tab too.

    so the simple solution is to let the <a> tag act as tab by putting back the # + id as in my example and hook the tabs ui event and procede from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.