Форма сборки Mootools

Итак, я пытаюсь создать собственный редактор в mootools и хочу использовать форму. Всякий раз, когда я пытаюсь создать форму, она просто создает <form class="inplaceeditor-form" method="post" action="#"/> Как мне сделать форму, в которую я могу вводить другие элементы?


person BiscottiGummyBears    schedule 18.01.2010    source источник


Ответы (1)


Вы должны создать другие элементы ввода, чтобы войти внутрь формы. Примерно так:

   // 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>

person iangraham    schedule 18.01.2010