2012-02-08 11 views
1

私はJQueryとJQueryUIの初心者で、私のプロジェクトでは.button().buttonset()という問題が発生しました。JQueryUIのチェックボックスはクリックできません。

私がJQueryUIページの例に従うと、すべて正常に動作します。しかし、私のページは機能としてボタンを作成しており、作成後はボタンのテキストが表示されますが、ボタンはクリックできません。 - $('#epcf-wrap').buttonset(); - クリック可能なボタンにはなりませんhttp://mdihosting.com/5/Projects/form/test1.html

この下のソースで追記した後:ここで

は、ソースリンクです。

私はまた、あなたがinputidに対応labelタグにfor属性を追加する必要が$('#epcf-wrap').buttonset('refresh');

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> 

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script> 
<script src="js/jquery.ui.selectmenu.js" type="text/javascript"></script> 
<script type="text/javascript" src="js/sliding.form.js"></script> 
<script src="js/jquery.ui.selectmenu.js" type="text/javascript"></script> 
<link rel="stylesheet" type="text/css" media="all" href="css/blitzer/jquery-ui-1.8.17.custom.css" /> 
<link rel="stylesheet" type="text/css" media="all" href="css/jquery.ui.selectmenu.css" /> 
<script type="text/javascript"> 
$(document).ready(function(){ 
    $('input:checkbox').button(); 
       $.ajax({ 
      type: "GET", 
      url: "xml/categories.xml", 
      dataType: "xml", 
      success: function(xml) { 
       var select = $('#vendorcat'); 
       $(xml).find('Cat').each(function(){ 
       var title = $(this).attr('name'); 
       select.append("<option class='vendorcat' value='"+title+"'>"+title+"</option>"); 
       $('#vendorcat').selectmenu(); 
       });  
      } 
     }); 

    $("#about").dialog({ 
    resizable: true, 
    autoOpen:false, 
    modal: true, 
    width:400, 
    height:400, 
    buttons: { 
    'Continue': function() { 
    $(this).dialog('close'); 
    alert('You clicked continue'); 
    }, // end continue button 
    Cancel: function() { 
    $(this).dialog('close'); 
    } //end cancel button 
    }//end buttons 

    });//end dialog 
    $('#results').hide(); 
    $('#btnOpen').click(function(){ 
    $('#about').dialog('open'); 
    }); //end click handler 

}); 

</script> 

<script type="text/javascript"> //onchange1 - Build Category Dropdown 
//Going for the single function length world record 
//Open categories.xml and find the node based upon the passed variable catname - Category Name 
//If the Category Name is equal to the argument passed build the variables, build the array, and output 
function onchange1(catname){ 
    $.ajax({ 
      type: "GET", 
      url: "xml/categories.xml", 
      dataType: "xml", 
      success: function(xml) { 
       var table = $('<table>', {id:'opttable', align:'left'}); 
       tr = $('<tr>').appendTo(table); // create TR and append to TABLE 
       td = $('<td>').appendTo(tr); // create TD and append to TR 
       // iterate all children of the current Category 
       $(xml).find('Cat[name="' + catname + '"]').children().each(function() { 
        d = $(this) 
        if (d.text() === 'TRUE') { 
         $('<input>', { 
         className: 'checkbox', 
         type: 'checkbox', 
         id: d.attr('id'), 
         name: d.attr('name'), 
         checked: 'checked' 
         }).appendTo(td); 
        } 
        else { 
         $('<input>', { 
         className: 'checkbox', 
         type: 'checkbox', 
         id: d.attr('id'), 
         name: d.attr('name') 
         }).appendTo(td); 
        } 
        // create LABEL with the id attribute of the current 
        // child of Cat and append to TD 
        $('<label>' + d.attr('name') + '</label>', { for:d.attr('id').toLowerCase() }) 
               .appendTo(td); 
        $('<br />').appendTo(td); // create BR element and append to TD 
       }); 
       $('#epcf-wrap').empty().append(table); // Append the table to its container 
       $('#epcf-wrap').buttonset();//This doesn't work 
      } 
    }); 
} 



</script> 
<script type="text/javascript"> //Form Submitted 
function formsubmitted(){ 
    var resultsArr = [] 
    resultsArr += "<table><tr><td>"; 
    resultsArr += "Name: " + $("input[name='name']").val(); 
    resultsArr += "</td></tr><tr><td>"; 
    resultsArr += "Email: " + $("input[name='email']").val(); 
    resultsArr += "</td></tr></table>" 

    $('#results').empty().append(resultsArr).show(); 
    $('#content').hide(); 
} 
</script> 

</head> 
<style> 
    span.reference{ 
     position:fixed; 
     right:5px; 
     top:5px; 
     font-size:10px; 
     text-shadow:1px 1px 1px #fff; 
    } 
    span.reference a{ 
     color:#555; 
     text-decoration:none; 
     text-transform:uppercase; 
    } 
    span.reference a:hover{ 
     color:#000; 

    } 
    h1{ 
     color:#ccc; 
     font-size:36px; 
     text-shadow:1px 1px 1px #fff; 
     padding:20px; 
    } 
</style> 
<body> 
    <div> 
     <span class="reference"> 

      <a href="javascript:modalbox();">Version popup could go here</a> 
    <input type="button" id="btnOpen" value="Open"> 
     </span> 
    </div> 
    <div id="content"> 
     <h1>VRACC</h1> 
     <div id="wrapper"> 
      <div id="steps"> 

       <form id="formElem" name="formElem" action="" method="post"> 
        <fieldset class="step"> 
         <legend>Vendor Details</legend> 
         <p> 
          <label for="vendorcat">Vendor Category</label> 
          <select id="vendorcat" name="vendorcat" onChange="onchange1((this).options[this.selectedIndex].value);"> 
          </select> 
         <legend>Enterprise Processes</legend> 

      <input type="checkbox" id="check1" /><label for="check1">Some Checkbox</label> 
      <div id="epcf-wrap" class="epcf-wrap"> 
      </div> 
        </fieldset> 

       </form> 
      </div> 
      <div id="navigation" style="display:none;"> 
       <ul> 

        <li> 
         <a href="#">Vendor Details</a> 
        </li> 

       </ul> 
      </div> 
     </div> 
    </div> 

</body> 

答えて

1

を試してみました。どんな理由であれ、あなたがfor属性を追加しているようでは、動作していないようです。そして、toLowerCase()を削除します。大文字と小文字は一致しない限り動作しません。それはまだ動作しない場合は、してみてください、

$('<label>' + d.attr('name') + '</label>', { for: d.attr('id') }) 

しかし: - idがなければならない、それは

$('<label for="' + d.attr('id') + '">' + d.attr('name') + '</label>' 

http://jsfiddle.net/CL9Tt/

+0

たことを

はたぶん、あなただけのforの後にスペースを必要とします一致 – ChadM

関連する問題