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

Can't create snippet from the <form> element #38

Closed
dbushenko opened this issue Dec 31, 2012 · 7 comments
Closed

Can't create snippet from the <form> element #38

dbushenko opened this issue Dec 31, 2012 · 7 comments

Comments

@dbushenko
Copy link

When using

    <div id="login-form">  . . . </div>

-- evrything works OK. But if I change that to

    <form id="login-form"> . . . </form> 

-- Enfocus can't create that snippet.

The code looks like this:

    (em/defsnippet login-form "/html/login.html" [:#login-form] [])
@ckirkendall
Copy link
Owner

I should be able to test this today. I am very interested in what is happening here as there should be no difference in a form vs a div as long as the id's don't conflict. Does the form have a name element.

@dbushenko
Copy link
Author

No, it doesn't.

@dbushenko
Copy link
Author

Also it skips the

    <script> . . . </script> 

elements. Sad. I need scripts in my snippets...

@ckirkendall
Copy link
Owner

Can you update your web sample with something that reproduce this issue and
the expected result so I can try to reproduce it.

CK

On Wed, Jan 2, 2013 at 7:47 AM, dbushenko notifications@github.com wrote:

Also it skips the . . . elements. Sad. I need scripts in my snippets...


Reply to this email directly or view it on GitHubhttps://github.com//issues/38#issuecomment-11806838.

@dbushenko
Copy link
Author

Looks like that might not be a bug, but a feature...

Although this feature is not so convinent to my mind. I have updated my project (https://github.com/dbushenko/websample), please have a look. In main.cljs I create the snippet my-snippet which contains the following html:

<div id="mytest">
  <script type="text/javascript">
alert("Hello, Creig!");
  </script>
  <div id="this">
  </div>
  Hello from Enfocus!
</div>

If you open the file snippets.html in your browser, you will certainly see the popup message. But when I create a snippet from this html and inject that snippet into main.html page, the javascript code is not evaluated. I cannot run any code when the snippet is shown; also I cannot add any definitions. E.g. when I change the js code to the following

  function myfunc() { alert("Hello, Creig!"); }

I still cannot use the function 'myfunc()'.

I don't know whether I have to complain about this issue, probably this behavior is explained by the architecture design.

@ckirkendall
Copy link
Owner

It is an architectural thing that prevents this but you might be able to get around it. let me think about it for awhile but I was thinking you could have a custom transform that could be run on script tag in the snippet (after you add it to the dom) that would eval that scripts. I have not tried the below snippet but it kind of what I am thinking.

(def evaljs
    (em/trans [node]  (js/eval (.innerHTML node))))

CK

@ckirkendall
Copy link
Owner

I am closing this issue because its not something we can fix and a work around was found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants