2010-01-18 67 views
1

所以我想在mootools中制作一个自定义编辑器,并且我想使用一个表单。每当我尝试创建一个表单时,它只会创建一个<form class="inplaceeditor-form" method="post" action="#"/>我怎样才能使它成为一个可以注入其他元素的表单?Mootools构建表格

回答

2

您必须创建其他输入元素才能进入表单。 类似这样的:

 
    // create the form element 
    var form = new Element('form', {'action' : 'your/action', 'class' : 'inplaceeditor-form'}); 
    //create the textbox 
    var textarea = new Element('textarea', {'name' : 'myTextarea'}); 
    //create the submit button 
var button = new Element('input', {'type' : 'submit', 'value' : 'Submit Me!'}); 
    // this puts the textarea and the button into the form 
    form.adopt(textarea,button); 
    // put the form inside what ever container you user 
    $('myContainer').adopt(form); 

    // the code above should give you this 
    <div id="myContainer"> 
     <form action="your/action" method="post" class="inplaceeditor-form"> 
      <textarea name="myTextarea"></textarea> 
      <input type="submit" value="Submit Me!" /> 
     </form>