jQuery UI Widgets › Forums › Editors › Button, RepeatButton, ToggleButton, LinkButton › Button doesn't work in Chrome
Tagged: jqwidgets buttons, jqxButton
This topic contains 2 replies, has 2 voices, and was last updated by Peter Sloth 11 years, 7 months ago.
-
Author
-
Hi
I have modified one of the demo pages slightly and suddenly buttons don’t work in Chrome!
The html is below.Any help is appreciated!
Thanks
//Peter
<!DOCTYPE html><html lang="en"><head> <title id='Description'>Test page</title> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css"> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.metro.css" type="text/css" /> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <script type="text/javascript" src="../../scripts/jquery-1.8.3.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxtree.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxexpander.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxsplitter.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = getDemoTheme(); theme = 'metro'; $("#jqxButton").jqxButton({ width: '150', theme: theme }); $("#jqxButton").on('click', function () { alert('Hello world'); }); // Create jqxTree $('#jqxTree').jqxTree({ theme: theme, height: '100%', width: '100%' }); $('#mainSplitter').jqxSplitter({ theme: theme, width: '100%', height: '100%', panels: [{ size: '20%' }, { size: '80%' }] }); $('#rightSplitter').jqxSplitter({ theme: theme, height: '100%', orientation: 'horizontal', panels: [{ size: '80%', collapsible: false }, { size: '20%' }] }); /* ==================== */ // prepare the data var data = new Array(); var firstNames = [ "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene" ]; var lastNames = [ "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier" ]; var productNames = [ "Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist" ]; var priceValues = [ "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0" ]; var available = [ "true", "false", "false", "false", "false", "true", "false", "false", "false", "false", "false", "false" ]; for (var i = 0; i < 200; i++) { var row = {}; var productindex = Math.floor(Math.random() * productNames.length); var price = parseFloat(priceValues[productindex]); var quantity = 1 + Math.round(Math.random() * 10); row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)]; row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)]; row["productname"] = productNames[productindex]; row["price"] = price; row["quantity"] = quantity; row["total"] = price * quantity; row["available"] = available[productindex]; row["summary"] = "<table><tr><td><b>" + "First name: " + "</b></td><td style='width=100%'>" + row["firstname"] + "</td></tr><tr><td><b>" + "Last name: " + "</b></td><td style='width=100%'>" + row["lastname"] + "</td></tr></table >"; data[i] = row; } var source = { localdata: data, datatype: "array", datafields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'available', type: 'bool' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }, { name: 'total', type: 'number' }, { name: 'summary', type: 'string' } ] }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { source: dataAdapter, width: '100%', height: '100%', altrows: true, theme: theme, columns: [ { text: 'Name', dataField: 'firstname', width: 100 }, { text: 'Last Name', dataField: 'lastname', width: 100 }, { text: 'Product', editable: false, dataField: 'productname', width: 180 }, { text: 'Available', editable: false, datafield: 'available', threestatecheckbox: true, columntype: 'checkbox', width: 70 }, { text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2' } ] }); $('#jqxgrid').jqxGrid({ altrows: true }); /* ==================== */ $("#jqxgrid").on('rowselect', function (event) { var summary = event.args.row.summary; $("#PreviewPanel").html("<div style='margin: 10px;'>" + summary + "</div>"); }); }); </script> <style type="text/css"> div#ContentPanel { padding: 0; overflow: hidden; } a:visited, a:hover, a:active { color: inherit; } html, body { height: 100%; width: 100%; margin: 0px; padding: 0px; overflow: hidden; } </style></head><body class='default'> <div id="mainSplitter"> <div> <div style="border: none;" id='jqxTree'> <ul> <li id="Mail" item-expanded='true'> <img style='float: left; margin-right: 5px;' src='../../images/mailIcon.png'><span item-title="true">Mail</span> <ul> <li id="Calendar" item-expanded='true'> <img style='float: left; margin-right: 5px;' src='../../images/calendarIcon.png'><span item-title="true">Calendar</span> </li> <li id="Contacts"> <img style='float: left; margin-right: 5px;' src='../../images/contactsIcon.png'><span item-title="true"><a style="text-decoration: none;" href="vq.htm?module=contacts">Contacts</a></span> </li> <li id="Inbox"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true"> <span><b>Inbox</b></span><span style='color: Blue'> (3)</span></span> <ul> <li id="jQWidgets"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">jQWidgets</span> <ul> <li id="Admin"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Admin</span> </li> <li id="Corporate"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Corporate</span> </li> <li id="Finance"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Finance</span> </li> <li id="Other"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Other</span> </li> </ul> </li> <li id="Personal"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Personal</span> </li> </ul> </li> <li id="Deleted Items" item-expanded='true'> <img style='float: left; margin-right: 5px;' src='../../images/recycle.png'><span item-title="true"> <span>Deleted Items</span><span style='color: Blue;'> (10)</span></span> <ul> <li id="Today"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Today</span> </li> <li id="Last Week"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Last Week</span> </li> <li id="Last Month"> <img style='float: left; margin-right: 5px;' src='../../images/folder.png'><span item-title="true">Last Month</span> </li> </ul> <li id="Notes"> <img style='float: left; margin-right: 5px;' src='../../images/notesIcon.png'><span item-title="true">Notes</span> </li> <li id="Settings"> <img style='float: left; margin-right: 5px;' src='../../images/settings.png'><span item-title="true">Settings</span> </li> <li id="Favorites"> <img style='float: left; margin-right: 5px;' src='../../images/favorites.png'><span item-title="true">Favorites</span> </li> </ul> </li> </ul> </div> </div> <div> <div id="rightSplitter"> <div id="ContentPanel"> <div style="position: absolute; height: 30px; width: 100%; background-color: lightgreen">Top Panel</div> <div style="position: absolute; top: 30px; height: 30px; width: 100%; background-color: lightsalmon; margin-bottom: 5px;"> <div> <input type="button" value="Button" id='jqxButton' /> </div> </div> <div style="position: absolute; box-sizing: border-box; -moz-box-sizing: border-box; padding-top: 65px; width: 100%; height: 100%;"> <div id="jqxgrid"></div> </div> </div> <div id="PreviewPanel"></div> </div> </div> </div></body></html>
Hi Peter,
On that page, the Button is placed in a DIV tag which has above it another DIV tag with higher z-index. So, it happens that the Mouse Events are handled by the Top-Most DIV tag. The solution is simple – set z-index of the DIV tags.
Example:
<div> <div id="rightSplitter"> <div id="ContentPanel"> <div style="z-index: 2; position: absolute; height: 30px; width: 100%; background-color: lightgreen">Top Panel</div> <div style="z-index: 3; position: absolute; top: 30px; height: 30px; width: 100%; background-color: lightsalmon; margin-bottom: 5px;"> <div> <input type="button" value="Button" id='jqxButton' /> </div> </div> <div style="z-index: 1; position: absolute; box-sizing: border-box; -moz-box-sizing: border-box; padding-top: 65px; width: 100%; height: 100%;"> <div id="jqxgrid"></div> </div> </div> <div id="PreviewPanel"></div> </div> </div> </div>
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Hi Peter
thanks for the answer.
It seems to work if I just remove the position: absolute from the div element which contains the grid.
Then I don’t need to worry about z-index 🙂thanks
//Peter
-
AuthorPosts
You must be logged in to reply to this topic.