0

I am trying to make some tabs that pull a webpart from the page and place the part in the tab, using Jquery's easyUI tabs. However, I am getting a syntax error in the following code:

    <!---->
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/themes/default/easyui.css">
    <script type="text/javascript" src="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/jquery.min.js"></script>
    <script type="text/javascript" src="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/jquery.easyui.min.js"></script>

    <script>
    var tabs = ['<id MSOZoneCell_WebPartWPQ12>', '<id MSOZoneCell_WebPartWPQ13>'];

    ExecuteOrDelayUntilScriptLoaded(initTabs, "sp.js");

    func initTabs(){ <----uncaught syntaxerror unexpected identifier
        //hide all of the webparts
        for(var i=0;i<tabs.length;i++){
        $('#' + tabs[i]).hide();
        }

        //show the first webpart in tab 1
    }

    function clickTab(id){
        for(var i=0;i<tabs.length;i++){
            if(tabs[i] === id){
                 $('#' + id).show(); 
            }else{
                 $('#' + tabs[i]).hide();
            }
        }
    }
    </script>

    <!---->


    <div class="easyui-tabs" style="width:1200px;height:1000px">
        <div title="Project Documents" style="padding:10px" onclick="clickTab('<id MSOZoneCell_WebPartWPQ12>')">

        </div>

        <div title="Project Updates" style="padding:10px" onclick="clickTab('<id MSOZoneCell_WebPartWPQ13>')">

        </div>
    </div>

I am using sharepoint online if that makes a difference.

  • 2
    Use "function" instead of "func" for the initTabs function. – Cecilia Jan 21 '17 at 8:05
0

Try the code after removing your comments. Sometime it happens that cause of comments code is not working desirably. And also there is correction in the line at which you are getting error and it is function instead of func.

    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/themes/default/easyui.css">
    <script type="text/javascript" src="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/jquery.min.js"></script>
    <script type="text/javascript" src="https://projectadvocatesllc.sharepoint.com/sites/project_sb3/SiteAssets/dev_jqueryui/jquery.easyui.min.js"></script>

    <script>
    var tabs = ['<id MSOZoneCell_WebPartWPQ12>', '<id MSOZoneCell_WebPartWPQ13>'];

    ExecuteOrDelayUntilScriptLoaded(initTabs, "sp.js");

    function initTabs(){
        for(var i=0;i<tabs.length;i++){
        $('#' + tabs[i]).hide();
        }    
    }

    function clickTab(id){
        for(var i=0;i<tabs.length;i++){
            if(tabs[i] === id){
                 $('#' + id).show(); 
            }else{
                 $('#' + tabs[i]).hide();
            }
        }
    }
    </script>

    <div class="easyui-tabs" style="width:1200px;height:1000px">
        <div title="Project Documents" style="padding:10px" onclick="clickTab('<id MSOZoneCell_WebPartWPQ12>')">

        </div>

        <div title="Project Updates" style="padding:10px" onclick="clickTab('<id MSOZoneCell_WebPartWPQ13>')">

        </div>
    </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.