EasyUI Forum
April 25, 2024, 02:17:38 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: Add a new easyui-switchbutton to s ul  (Read 4414 times)
kayjay
Newbie
*
Posts: 10


View Profile Email
« on: February 14, 2017, 10:02:59 AM »

I have this html snippet taken from one of the mobile tab demos.

Code:
<!--Second Tab-->
 <div style="padding:10px">
<div class="panel-header tt-inner">
<img src='images/scanner.png'/><br>P2
</div>
        <ul id="main_list" class="m-list">
            <li>
                <span>Network</span>
                <div class="m-right"><input id="sb1" class="easyui-switchbutton" checked></div>
            </li>
            <li>
                <span>Bluetooth</span>
                <div class="m-right"><input id="sb2" class="easyui-switchbutton" checked></div>
            </li>
</ul>
     </div>

I have this js code inside the ready function:

Code:
$('#main_list').append('<li><span>NewListItem</span><div class="m-right"><input id="sb3" class="easyui-switchbutton"></div></li>');

When this loads I get a new list element but instead of an "easyui-switchbutton" I get a "text input box" instead. Should I expect this to work ror have I got it all wrong?
« Last Edit: February 14, 2017, 10:18:26 AM by kayjay » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 15, 2017, 01:37:53 AM »

You have to create the switchbutton after appending the elements.
Code:
$('#main_list').append('<li><span>NewListItem</span><div class="m-right"><input id="sb3" class="easyui-switchbutton"></div></li>');
$('#sb3').switchbutton();
Logged
kayjay
Newbie
*
Posts: 10


View Profile Email
« Reply #2 on: February 15, 2017, 02:48:08 AM »

Thank you so much - that does the trick. Silly me.
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!