PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/documentation/appframework/$.create.md

https://github.com/maoyao/appframework
Markdown | 50 lines | 31 code | 19 blank | 0 comment | 0 complexity | 048abcb65f1c7dc451c02e2aae995854 MD5 | raw file
  1. #$.create(type,[params])
  2. ```
  3. $.create - a faster alertnative to $("this is some text");
  4. ```
  5. ##Example
  6. ```
  7. $.create("div",{id:"main",innerHTML:"this is some text"});
  8. $.create("this is some text");
  9. ```
  10. ##Parameters
  11. ```
  12. DOM String
  13. properties [Object]
  14. ```
  15. ##Returns
  16. ```
  17. Object Returns an appframework object
  18. ```
  19. ##Detail
  20. $.create(type,[params]) is new for 2.0. It is a faster, and sometimes "safter" way to create DOM Nodes.
  21. $.create allows you to bypass logic inside the $() engine and jump right to element creation. It returns an App Framework collection.
  22. $.create works two ways.
  23. <ol>
  24. <li>Parse a string and return the DOM elements (slower)</li>
  25. <li>Create the element using document.createElement and setting properties (faster)</li>
  26. </ol>
  27. Below are two examples that provide the same node. The first is faster.
  28. ```
  29. var faster=$.create("div",{id:"test",html:"Test HTML"})
  30. var slower=$.create(" < div id='test'>Test HTML< /div> ");
  31. ```