2010-01-18 46 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>