I have a navigation menu that I need to enable on all my pages .... via jsp I just include in this menu
<div id="header"><jsp:include page="../menu_v1.jsp"/></div>
but the problem is that my menu contains <html><head></head><body></body></html> Now that I want to use my jqGrid, which is defined on my new page inside <script></script> , it does not appear .... because it contradicts my jquery script header ... My tested solutions:
- Using an
iframe , but that will not allow me to control my other pages. - Instead of including
<jsp:include page=""/> I can simply include all components with jquery navigation on each page under the same script ... Which is probably not a good solution, since whenever I need include more components in my menu than I have to make changes on every page ...
If anyone has a better solution ... please let me know .... thanks!
Update: Code of my main menu
<script type="text/javascript"> //<![CDATA[ var navMenu = function(){ jQuery("ul.subnav").parent().append("<span></span>"); jQuery("ul.topnav li span").hover(function() { jQuery(this).parent().find("ul.subnav").slideDown('fast').show(); jQuery(this).parent().hover(function() { }, function(){ jQuery(this).parent().find("ul.subnav").slideUp('slow'); }); }).hover(function() { jQuery(this).addClass("subhover"); }, function(){ jQuery(this).removeClass("subhover"); }); } //]]> </script> <div id="topbar"> <div class="disclaimer"></div> <ul class="topnav"> <li> <a href="#">Order Management</a> <ul class="subnav"> <li><a href="<%=request.getContextPath()%>/jsp/1.jsp">1</a></li> <li><a href="<%=request.getContextPath() %>/jsp/2.jsp">2</a></li> </ul> </li> <li> <a href="#">3</a> <ul class="subnav"> <li><a href="<%=request.getContextPath()%>/3.jsp">3</a></li> </ul> </li> <li> <a href="#">4</a> <ul class="subnav"> <li><a href="<%=request.getContextPath()%>/4.1.do">4.1</a></li> <li><a href="<%=request.getContextPath()%>/jsp/4.2.jsp">Add Spog</a></li> <li><a href="<%=request.getContextPath()%>/jsp/4.3.jsp">4.3</a></li> </ul> </li> </ul> </div>
another page using the menu:
script type="text/javascript"> //<![CDATA[ jQuery(document).ready(function(){ navMenu(); jQuery("#test").jqGrid({ sortable:true, url: '', datatype:'json', colNames:['col1','col2', 'col3'], colModel:[ {name:'col1',index:'col1', width:85, sorttype:"int", align:"center", key:true}, {name:'col2',index:'col2', width:40, sorttype:"int", align:"center"}, {name:'col3',index:'col3', width:100, align:"center"}, ], rowNum:10, rowList:[10,20,30], jsonReader : {repeatitems: false, root: function(obj) { return obj; }, page: function (obj) { return 1; }, total: function (obj) { return 1; }, records: function (obj) { return obj.length; } }, pager: '#pager', sortname: 'col1', sortorder: "desc", loadonce:true, viewrecords: true, multiselect: true, caption: "Test", height:230 }); jQuery("#test").jqGrid('navGrid','#pager10',{view:true,add:false,edit:false,del:false, searchtext:'Filter'},{},{},{},{multipleSearch:true}); jQuery("#test").jqGrid('hideCol', 'cb'); }) ; //]]> </script> </head> <body> <div id="header"><jsp:include page="../menu_v1.jsp"/></div>
But now the problem is that my menu and main jqGrid do not work at all ...