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

cat not use jQuary plugin to template #51

Closed
piyalmaduranga opened this issue Mar 9, 2017 · 2 comments
Closed

cat not use jQuary plugin to template #51

piyalmaduranga opened this issue Mar 9, 2017 · 2 comments
Labels

Comments

@piyalmaduranga
Copy link

piyalmaduranga commented Mar 9, 2017

I am using grapejs to load my html template and editing that template.In my template I use jQuery plugin.And also we use jQuery for building up editor using grapejs. In that case there is happen conflict
between those jQuery loading on time.
i had error like this
screenshot from 2017-03-09 12 48 33

how to void that kind of issue,
can we use jquary for template ?
if it is , how can i achieve ?

@piyalmaduranga piyalmaduranga changed the title cat not use jquary Library to template cat not use jQuary plugin to template Mar 9, 2017
@artf
Copy link
Member

artf commented Mar 12, 2017

I think this what happens

<!-- Here you load all the stuff for GrapesJS -->
<script src="path/to/jquery.js"></script>
<script src="path/to/grapes.min.js"></script>

<div id="gjs">
  <div class="txt-red">Hello world!</div>
  <style>.txt-red{color: red}</style>
  <!--
  Before the editor's work this script will be loaded by the main document
  and will overwrite the one you've loaded before (so you'll break deps for GrapesJS)
  -->
  <script src="path/to/some-other-jquery.min.js"></script>
</div>

<script type="text/javascript">
  var editor = grapesjs.init({...});
</script>

Honestly I've not played too much with scripts inside templates but I'm working on it in this days.

For now I'd suggest to add scripts after

var editor = grapesjs.init({...});
var dc = editor.DomComponents.getComponents();
dc.add(`<script>
var execScripts = function(e){
 // ...
};
var script = document.createElement('script');
script.onload = execScripts;
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js';
document.body.appendChild(script);
</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

2 participants