Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to support bootstrap #133

Closed
dreamhuo opened this issue Jun 30, 2017 · 14 comments
Closed

How to support bootstrap #133

dreamhuo opened this issue Jun 30, 2017 · 14 comments
Labels

Comments

@dreamhuo
Copy link

Hi, I want to edit the bootstrap template with grapesjs, but it doesn't work. How to do reference bootstrapJS in grapesjs? And let both work.

@dreamhuo
Copy link
Author

thanks

@artf
Copy link
Member

artf commented Jun 30, 2017

You can place the bootstrap's <link> directly inside your template (same question #27).

@artf artf closed this as completed Jun 30, 2017
@dreamhuo
Copy link
Author

dreamhuo commented Jul 3, 2017

qq 20170703101839
qq 20170703102100

@dreamhuo
Copy link
Author

dreamhuo commented Jul 3, 2017

Look at the pictures, for example:
Add
<script src="dist/jquery-3.2.1.min.js"></script> <script src="demo/assets/js/bootstrap.min.js"></script>
in grapesjs is not work.
It's normal to delete it.

@dreamhuo
Copy link
Author

dreamhuo commented Jul 3, 2017

<div id="gjs">
      <!--code…-->
      <script src="dist/jquery-3.2.1.min.js"></script>
      <script src="demo/assets/js/bootstrap.min.js"></script>
 </div>

@artf
Copy link
Member

artf commented Jul 3, 2017

@dreamhuo adding JS is slightly different from adding CSS (same as #51) and as in this case, it breaks stuff. I'd suggest you adding JS after the render

editor.addComponents(`
<script src="dist/jquery-3.2.1.min.js"></script>
<script src="demo/assets/js/bootstrap.min.js"></script>
`)

or even better try to load your template via config

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
      container : '#gjs',
      components: `
        <div>...</div>
        <script src="dist/jquery-3.2.1.min.js"></script>
        <script src="demo/assets/js/bootstrap.min.js"></script>
      `,
      style: '.txt-red{color: red}',
  });
</script>

@dreamhuo
Copy link
Author

dreamhuo commented Jul 4, 2017

Master, on your way, I always make mistakes here:
Uncaught SyntaxError: Invalid or unexpected token

@dreamhuo
Copy link
Author

dreamhuo commented Jul 4, 2017

qq 20170704100139
qq 20170704100156

@dreamhuo
Copy link
Author

dreamhuo commented Jul 4, 2017

The same is true of the addComponents method.

@dreamhuo
Copy link
Author

dreamhuo commented Jul 4, 2017

@artf
Hi Master, I solved the mistake,splitting the script:

qq 20170704101407
But code is not neat, is there a better way?

@artf
Copy link
Member

artf commented Jul 4, 2017

Seems like browser's parser issue, can't do a lot, you might try with '<\/script>' if you want

@dreamhuo
Copy link
Author

dreamhuo commented Jul 5, 2017

Thank you very much for your patience. @artf

@shimulch
Copy link

I have faced same issue. But escaping / character solved my problem.
ex.

editor.addComponents('<script src="../somejs.js"><\/script>')

@lock
Copy link

lock bot commented Sep 18, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the outdated label Sep 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants