require-js.rst 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. RequireJS Support
  2. =================
  3. If your application relies on RequireJS, we recommend you to enable its
  4. support. The bundle will automatically wrap the CKEditor instantiation into
  5. a ``require`` block making the code more reliable.
  6. Configure RequireJS
  7. -------------------
  8. The first step is to configure RequireJS in order to make it aware of where
  9. CKEditor is located. For that, you can use the following snippet:
  10. .. code-block:: js
  11. {
  12. paths: {
  13. 'ckeditor': '{{ asset("bundles/fosckeditor/ckeditor") }}'
  14. },
  15. shim: {
  16. 'ckeditor': {
  17. deps: ['jQuery'],
  18. exports: 'CKEDITOR'
  19. }
  20. }
  21. }
  22. Enable RequireJS
  23. ----------------
  24. The second step is to enable RequireJS in the bundle. To do so, you can
  25. configure it globally in you configuration:
  26. .. code-block:: yaml
  27. # app/config/config.yml
  28. fos_ck_editor:
  29. require_js: true
  30. Or you can configure it in your widget:
  31. .. code-block:: php
  32. $builder->add('field', 'ckeditor', array('require_js' => true));