jQuery UI Widgets › Forums › Editors › Button, RepeatButton, ToggleButton, LinkButton › Template on jqxButtonGroup
Tagged: Button, group, jqxbuttongroup, template
This topic contains 4 replies, has 2 voices, and was last updated by pribadip 9 years, 4 months ago.
-
Author
-
Hi,
Is it possible to add template on jqxButtonGroup (Button Group)?
So at the Button Group there are several buttons with different colors (primary, info, success, warning, danger, inverse).
Thank you.You can access all the buttons via their IDs.
If the buttons don’t have IDs You must create them.Below is shown the way to make the relation betwen IDs and templates.
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>The jqxButtonGroup widget creates a set of buttons that can work as normal buttons, radio buttons or checkboxes.</title> <link rel="stylesheet" href="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/scripts/demos.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxbuttongroup.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxbuttons.js"></script> </head> <body class='default'> <div id='content'> <script type="text/javascript"> $(document).ready(function () { // Create jqxButtonGroup. $("#jqxWidget").jqxButtonGroup({ mode: 'default' }); // Add templates to the jqxButtons. $("#Left").jqxButton({ template: "info" }); $("#Center").jqxButton({ template: "success" }); $("#Right").jqxButton({ template: "warning" }); }); </script> <div id='jqxWidget'> <button style="padding:4px 16px;" id="Left"> Left </button> <button style="padding:4px 16px;" id="Center"> Center </button> <button style="padding:4px 16px;" id="Right"> Right </button> </div> </div> </body> </html>
Best Regards,
Ivaylo IvanovjQWidgets Team
http://www.jqwidgets.comHi Ivaylo, thanks for your response.
It’s great example. But perhaps we need to add pressed style for template button. Because it seems template button does not have pressed style. So it looks like there is no difference pressed or not. I mean in case we use mode ‘radio’ or ‘checkbox’.Best Regards,
Pribadi PamungkasHi Pribadi Pamungkas,
You can add some CSS styles to detect when some button is pressed and then change the style.
Here is an example.
<!DOCTYPE html> <html lang="en"> <head> <title id='Description'>The jqxButtonGroup widget creates a set of buttons that can work as normal buttons, radio buttons or checkboxes.</title> <link rel="stylesheet" href="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/scripts/demos.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxbuttongroup.js"></script> <script type="text/javascript" src="http://www.jqwidgets.com/jquery-widgets-demo/jqwidgets/jqxbuttons.js"></script> <style> .jqx-group-button-pressed.jqx-success { background-color: #ff0000 !important; color: #aaaaaa !important; background-image: none !important; } </style> </head> <body class='default'> <div id='content'> <script type="text/javascript"> $(document).ready(function () { // Create jqxButtonGroup. $("#jqxWidget").jqxButtonGroup({ mode: 'checkbox' }); // Add templates to the jqxButtons. $("#Left").jqxButton({ template: "success" }); $("#Center").jqxButton({ template: "success" }); $("#Right").jqxButton({ template: "success" }); }); </script> <div id='jqxWidget'> <button style="padding:4px 16px;" id="Left"> Left </button> <button style="padding:4px 16px;" id="Center"> Center </button> <button style="padding:4px 16px;" id="Right"> Right </button> </div> </div> </body> </html>
Best Regards,
Ivaylo IvanovjQWidgets Team
http://www.jqwidgets.comThank you
-
AuthorPosts
You must be logged in to reply to this topic.