PDA

View Full Version : installing Disqus comments in Sencha Touch /Architect



detp
19 Oct 2012, 4:14 AM
Hi Please I am hoping the sencha guru's can help me with the following problem. I am trying to install disqus comments using its universal javascript code. I am trying to place the script inside the html section of an actionsheet, however I keep on receiving errors and it fails to load the application.

The code is
Disqus:
<div id="disqus_thread"></div><script type="text/javascript">var disqus_shortname = 'myafricancanvas'; function() { var dsq = document.createElement('script');dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();</script><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered byDisqus.</a></noscript><a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>


My Sencha markup is as follows:

Ext.define('MyApp.view.SocialShare', {
extend: 'Ext.ActionSheet',
alias: 'widget.Social',


config: {
height: 450,
html: '<div id="disqus_thread"></div><script type="text/javascript">var disqus_shortname = 'myafricancanvas'; function() { var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();</script><noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered byDisqus.</a></noscript><a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>',
style: 'background:#000;',
zIndex: 90,
modal: false,
scrollable: 'vertical',
items: [
{
xtype: 'button',
docked: 'right',
height: 50,
itemId: 'shareclose',
width: 50,
icon: 'addresources/close.png'
}
],
listeners: [
{
fn: 'onMybutton4Tap',
event: 'tap',
delegate: '#shareclose'
}
]
},


onMybutton4Tap: function(button, e, options) {
this.hide();
}


});


The app thru up the following errors in debug mode:

Uncaught SyntaxError: Unexpected identifier app/view/SocialShare.js?_dc=1345723248496:22Uncaught Error: The following classes are not declared even if their files have been loaded: 'MyApp.view.SocialShare'. Please check the source code of their corresponding files for possible typos: 'app/view/SocialShare.js sencha-touch-all-debug.js:798
Please I would be extremely grateful if someone can advise how to overcome this problem as I am under extreme pressure. It is probably just a syntax issue.

I am happy to send the url of the app via PM if required.
:(( I decided to use a smiley as I dont see to many on the forum lol

Thanks in advance.

mitchellsimoens
19 Oct 2012, 7:42 AM
The html is not valid, you have to escape the quotes.

detp
19 Oct 2012, 8:12 AM
Thanks Mitchel

Here comes a silly question, not quite sure what you mean "escape the quotes" can you pls give an example with the html I provided.

Promise to add the whole solution for others in the forum.

Thanks.

mitchellsimoens
19 Oct 2012, 8:52 AM
html : 'some text here, isn\'t it good?'

red text is an escaped single-quote

detp
19 Oct 2012, 9:31 AM
Tried escaping quotes but still doesnt seems to be working.

<div id="disqus_thread"></div> <script type="text/javascript"> var disqus_shortname = \'myafricancanvas\'; (function() { var dsq = document.createElement(\'script\'); dsq.type = \'text/javascript\'; dsq.async = true; dsq.src = \'http://\' + disqus_shortname + \'.disqus.com/embed.js\'; (document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(dsq);})();</script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript><a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

detp
22 Oct 2012, 12:12 AM
Can anyone in the forum please provide some help? I have tried a number of solutions none are yet to work. My javascript debugging skills are very limited.

Thanks

shepsii
22 Oct 2012, 7:29 AM
Why don't you start with the html set to "hello" then put the disqus HTML in piece by piece until it works or breaks? Then you know that the little segment you just added didn't work and needs escaping or formatting correctly inside the single quotes.

detp
22 Oct 2012, 8:50 AM
Hi Shepsii

Thanks I have tried that as well, the Disqus code comes in three parts and requires all the parts.

I am sure it is something trivial I am missing.

detp
25 Oct 2012, 11:58 AM
Can somebody on this forum please have the kindness of heart to help with this particular problem.
Before offering solutions please test or if posible have experienced the problem.

if I could I would happily pay for premium support.

Thanks and blessings in advance