Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery UI按钮设置在复制的HTML上失败 1. 2. 函数replaceAll(查找、替换、str){ 返回str.replace(新的RegExp(查找'g'),replace); } //将tab_收音机的html从TabTemplate复制到RealTab $('#RealTab').html(replaceAll('tab#','tab1#',$('#TabTemplate').html()); $('tab1#radios')。按钮集(); $('tab1_radios:input').change(function(){alert(“click”);});_Jquery_Jquery Ui - Fatal编程技术网

JQuery UI按钮设置在复制的HTML上失败 1. 2. 函数replaceAll(查找、替换、str){ 返回str.replace(新的RegExp(查找'g'),replace); } //将tab_收音机的html从TabTemplate复制到RealTab $('#RealTab').html(replaceAll('tab#','tab1#',$('#TabTemplate').html()); $('tab1#radios')。按钮集(); $('tab1_radios:input').change(function(){alert(“click”);});

JQuery UI按钮设置在复制的HTML上失败 1. 2. 函数replaceAll(查找、替换、str){ 返回str.replace(新的RegExp(查找'g'),replace); } //将tab_收音机的html从TabTemplate复制到RealTab $('#RealTab').html(replaceAll('tab#','tab1#',$('#TabTemplate').html()); $('tab1#radios')。按钮集(); $('tab1_radios:input').change(function(){alert(“click”);});,jquery,jquery-ui,Jquery,Jquery Ui,请参阅(由更大的代码简化而成) 我的HTML包含一个带有单选按钮的隐藏TemplateTab div和一个空RealTab div 首先,我将内部HTML从TemplateTab复制到RealTab,并将ids标签中的所有tab_uuuu替换为tab1_uuuu,等等 然后调用tab1_radios上的buttonset()并附加一个更改事件 但是,单击按钮会导致JQuery异常“无法在初始化之前调用按钮上的方法”-为什么 请注意,删除buttonset()调用会生成一个(丑陋的)单选按钮,它可

请参阅(由更大的代码简化而成)

我的HTML包含一个带有单选按钮的隐藏TemplateTab div和一个空RealTab div

首先,我将内部HTML从TemplateTab复制到RealTab,并将ids标签中的所有tab_uuuu替换为tab1_uuuu,等等

然后调用tab1_radios上的buttonset()并附加一个更改事件

但是,单击按钮会导致JQuery异常“无法在初始化之前调用按钮上的方法”-为什么

请注意,删除buttonset()调用会生成一个(丑陋的)单选按钮,它可以很好地处理事件

谢谢大家!

radioGroup()会拾取所有共享单选按钮名称的内容,因此需要更改新创建的单选输入的名称

这是一把可以使用的小提琴--用于概念验证,但我相信你可以找到一种更干净的方法:)

radioGroup()将拾取所有共享单选按钮名称的内容,因此您需要更改新创建的单选输入的名称

这是一把可以使用的小提琴--用于概念验证,但我相信你可以找到一种更干净的方法:)

<div id="TabTemplate" style="display: none;">
    <span id="tab_radios">
        <input type="radio" id="tab_l1" name="layout"/>  
        <label for="tab_l1">1</label>
        <input type="radio" id="tab_l2" name="layout" checked="checked" />  
        <label for="tab_l2">2</label>
    </span>
</div>

<div id="RealTab">
</div>

function replaceAll(find, replace, str) {
    return str.replace(new RegExp(find, 'g'), replace);
}

// copy tab_radios's html from TabTemplate to RealTab
$('#RealTab').html(replaceAll('tab_', 'tab1_', $('#TabTemplate').html()));
$('#tab1_radios').buttonset();
$('#tab1_radios :input').change(function() { alert("click"); });
    function replaceAll(find, replace, str) {
      return str.replace(new RegExp(find, 'g'), replace);
   }

    // copy tab_radios's html from TabTemplate to RealTab
    $('#RealTab').html(replaceAll('tab_', 'tab1_', $('#TabTemplate').html()));

   //change the names of the radio inputs
   $('#tab_l1').attr('name', 'layout1');
   $('#tab_l2').attr('name', 'layout1');
   $('#tab1_radios').buttonset();
   $('#tab1_radios :input').change(function() { alert("click"); });