EasyUI Forum
May 21, 2024, 10:21:21 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Backend developer treading UI waters - HELP needed  (Read 5033 times)
CosmicRider
Newbie
*
Posts: 3


View Profile
« on: February 18, 2014, 09:56:03 AM »

I have a EasyUI Tab Panel
Inside a Tab Pane I have several EasyUI Panels, each representing a set of data, contained in labels.
I am using RAILS

I have a backend service that is sending data for a panel back in JSON
Question: How do I update the panel labels with the JSON data?

As an Example:
EasyUI TabPanel id="foo"
EasyUI Panel inside of "foo" has labels:
A
B
C

JSON data has

A: Apple
B: Banana
C: Cherry

Code example greatly appreciated!
thanks in advance
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 19, 2014, 01:09:14 AM »

Find an element and you can use '.text()' or '.html()' to update its value. Here is an example shows how to do this.
Code:
<div id="foo" class="easyui-tabs" style="width:600px;height:300px">
    <div title="Tab1">
        <p><label id="l-A"></label></p>
        <p><label id="l-B"></label></p>
        <p><label id="l-C"></label></p>
    </div>
</div>
<script type="text/javascript">
$(function(){
    var data = {
        A: 'Apple',
        B: 'Banana',
        C: 'Cherry'
    };
    for(var k in data){
        var v = data[k];
        $('#l-'+k).html(v);
    }
});
</script>
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!