简体   繁体   中英

why second time button click not work properly?

i am making a row on button click.First time it work fine please expand and check .but hen i click second time it not make same as first. http://jsfiddle.net/R2DzV/5/

$(document).ready(function(){
    $('.btn_handler').click(function(){
 $("#list").append('<li><div data-role="collapsible"><h3>name</h3><ul><li><div fieldset data-role="controlgroup" id="Smoker"><input type="radio" name="radio-choice" id="radio-choice-1" value="TestCase" checked="checked"><label for="radio-choice-1">Add Test Case</label><input type="radio" name="radio-choice" id="radio-choice-2" value="TestCommand"><label for="radio-choice-2">Add Test Command</label></fieldset>' + '<a  data-role="button" data-mini="true" data-theme="a">Add</a></div></li></ul></div></li>');   
        $('#list').trigger('create');
        $('#list').listview('refresh');

    })

});

Your code has duplicate IDs being generated.

Remove the id="Smoker" and learn something new:

<label><input type="radio" /> Click the text and the radio button gets it!</label>

Replace this in your .append() :

<div fieldset data-role="controlgroup" id="Smoker">

with:

<fieldset data-role="controlgroup" id="Smoker">

And then fix the obvious problem that you should only have unique ID's (you can maybe make them classes instead).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM