-
Notifications
You must be signed in to change notification settings - Fork 71
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
Modified to run JavaScript #8
Conversation
This doesn't really seem like a good idea -- besides the issues of using eval, the whole idea of hinclude is that it's not tied deeply to javascript. |
I agree about using eval but if you have to use hinclude on factors such as the box of facebook, javascript that parses not function because the node is not found and loaded ... this is a limitation of hinclude |
Hmm. I'd prefer to have the option to run any scripts inside of the included content upon load. I.e., if I include foo/bar.html, and it contains a script tag, that gets loaded upon inclusion. Would that work for your use case? If not, could you talk more about what you want to do? |
you're right, I have to allow the execution of all scripts..
here.html content: Title box<fb:fan profile_id="profileid" stream="0" logobar="0" connections="6" width="214" height="270" css="css"></fb:fan> text info <script>FB.XFBML.parse();</script> in this case the javascript is not executed but displayed on the screen |
This still has the script page in the page doing the inclusion, rather than the included text. I was talking about the latter. |
corrected issue, changed management content for better content integration, included variable for removal javascript and meta |
…o body, corrected display structure html
+1 |
I am also looking for a way to achieve this. I use hinclude in Symfony2 to load embedded controllers (which are widgets, in my case) containing javascripts. So: +1 |
Same problem as Dirkluijk on Symfony2. s7ntech's version is working but with only one hx:include call, when i have more than one i randomly get : Uncaught TypeError: Object [object global] has no method 'hinclude_check_content' hinclude.js:68 Is hinclude really designed to this ? I may move to another solution. |
you can have a sample code of the page? and version of browser you are using? thanks |
I have a render_hinclude (from Symfony2) inside a for loop :
Which is creating the hx:include tag and content. The content is simple HTML with jQuery inside it (inside script tag). I'm generating random ids (since the content is almost the same, to avoid conflict with JS). As i said, sometimes it's working well (when XHR calls are done with a little delay), when they're done at almost the same time i've got this error. |
The reason I want any JavaScript code included to be executed, is that it needs elements from the DOM to be loaded. Example:
Currently this won't work when included with hinclude.js. s7ntech' version executes the embedded JavaScript code, but not the referenced script. Note that jQuery's 'load()' function evaluates included Javascript fine. Maybe it's worth looking at its implementation. When I already include the Javascript in the DOM (outside the <hx:include /> part, the DOM elements I need are not yet available. |
… variable content
the reported problem by TheNuks has been corrected the cause was a conflict with external libraries, especially facebook_connect, which generated errors chain has changed the reference to methods and added control over the type of the variable |
Thank-you ! It's working fine now :) Will you implement external .js too someday? |
if I understand it, the reported problem by dirkluijk has been corrected |
s7ntech, great, thanks! It works now. The only problem is that I now have scope issues. Example:
In library.js:
In myscript.js:
(Just a simple example, real world use case is more complicated) Results in: For now I can put the library.js in the document (outside the This problem appears in Chrome/Firefox/Safari, on IE9 I got an JS error on hinclude.js:91 ( |
Does this work now? I have HIncluded content containing <script/> tags, and they do not render out to the user as text, but neither do they execute. In my use case, I'm displaying a message to the user via HInclude, and that message contains a dynamically created div, which is intended to show them the badge they just earned: <div class="alert alert-success">
<script type="text/javascript">
var badgeData = {
department: '_none',
description: 'Add your gender to your profile',
name: 'Engendering Dialog',
tag: 'profile_gender',
pointValue: 25,
level:
};
var badgeOptions = {
size: 'small'
};
renderUserBadge(badgeData, badgeOptions);
</script>
You've earned the "Engendering Dialog" badge: <em>Add your gender to your profile</em> (25 points)
</div> EDIT: Turns out I'm getting an error when I use b96306f:
|
Good evening, to help solve the problem, it would be possible to have a practical example also of "renderUserBadge" and version of browser used? would also be useful to know where it is defined. Thank you for the help |
👍 |
+1 |
Hi, big +1 for this feature. But I have an issue with the f5c585b version :
It works well if I remove |
👍 |
2 similar comments
+1 |
+1 |
On the road (in China) at the moment, but will review and merge in ASAP -- don't worry, won't take any other pulls until I get to this :) Thanks much, |
@s7ntech i have some troubles with the 35e486c version when i'm trying to parse and serialize a textarea :
the same with div element :
do you have an idea ? |
@s7ntech you have a bug in :
example :
|
I thank you for reporting, I will try a generic expression that handles tags and that will not cause further problems with the rest of the source |
the behavior is the same for each tag, it is a problem caused by DOMParser, to overcome this I thought about using a regular expression to make the correction, but as you can see I did not tenuno consider several case studies |
👍 |
+1! |
Thanks for the patch. |
+1 |
1 similar comment
+1 |
Agreed that #28 is much less intrusive. |
Permitted execution javascript code after loading 'hx:include' in the particular case where the content has the JavaScript code that is executed before 'hinclude' finish on its own, for example widget facebook