EasyUI Forum
November 30, 2025, 02:36:37 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Change easyui Theme dynamically  (Read 10191 times)
sky-t
Full Member
***
Posts: 145


View Profile
« on: March 29, 2019, 11:54:11 PM »

Hi there,

is there a possibility to change current easy Theme on the fly?

Just switch for example from dark to default and all components are changing to the new theme without reloading the page?


Thanks
Logged
jahangir
Jr. Member
**
Posts: 51



View Profile Email
« Reply #1 on: March 30, 2019, 02:31:59 AM »

1- First of all give an id to your theme style sheet link.

Code:
<link id="theme_style" rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">

2- Add following javascript code.

Code:
<script>  
        /*declare variable to store theme style sheet links*/
var theme_styles = {
'default': 'http://www.jeasyui.com/easyui/themes/default/easyui.css',
'black': 'http://www.jeasyui.com/easyui/themes/black/easyui.css',
'gray': 'http://www.jeasyui.com/easyui/themes/gray/easyui.css'       
};
   
/*function to change themes*/
function changetheme(themname){
$('#theme_style').attr('href', theme_styles[themname]);
}       
</script>

3- Calll the changetheme function by passing your theme name as parameter .

Code:
changetheme('black');


Please see attached example file.
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #2 on: March 30, 2019, 02:44:47 AM »

Hi jahangir,

works like a charme - THANK YOU so much and have a nice weekend!!!!!!!!!!!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!