EasyUI Forum
September 13, 2025, 11:21:35 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: Dynamic Language Translation [solved]  (Read 7374 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: November 14, 2016, 09:20:04 PM »

I need to be able to hook into an event that is fired before any easyui element is rendered in order to switch it's label text with the language of the user.

I already have this working for Input Labels and are for datagrid are using the onBeforeOpen() event, but the change of text is visible to the user and they can see it change, I need to change it before the element is rendered.

If I don't add a delay to push it to the bottom of the stack, then the translation does not work as the element are not yet created.

Code:
  onBeforeOpen: function(){
    var me = $(this);
    setTimeout(function(){
      me.find('tr.datagrid-header-row td[field] .datagrid-cell > span:first-of-type').each(function(){
        $(this).text(eui.translate($(this).text()));
      })
    })
  }


I am really looking for a method that I can use globally, or an event that is fired for every element just before it gets rendered in order to change the label without the user seeing the change ?!


« Last Edit: November 17, 2016, 07:47:29 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: November 15, 2016, 12:08:21 AM »

Any easyui components can be defined in html markups that have 'easyui-...' class. When the components are parsed completely, the $.parser.onComplete event fires. This event can be considered as the hook that triggered after creating the components.
Code:
<script type="text/javascript">
    $.parser.onComplete = function(){
        $('.datagrid-f').each(function(){
            var dg = $(this);
            var me = dg.datagrid('getPanel');
            me.find(...).each(function(){
                //...
            });
        });
    }
</script>
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: November 17, 2016, 07:47:14 AM »

Thanks so much, that will work.
Logged

-- Licensed User --
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!