PDA

View Full Version : javascript in html



scotthathaway
14 Dec 2009, 9:03 AM
I have a panel and in the html I want to put a javascript. I can't figure out how to do it. I saw a post that said I could put scripts: true if I was using an autoLoader, but I am not. Can you help?

var test = new Ext.Panel ({
title: 'hi',
html: "<script>alert('hi');</script>"
})

I am obviously brand new to Ext JS.

Thanks,
Scott

14 Dec 2009, 9:18 AM
Hi Scott,

I don't understand why you're doing this. Can you explain why and perhaps we can help you find a solution.

scotthathaway
14 Dec 2009, 10:46 AM
The example is obviously bogus. I have a set of PHP controls that output javascript to build various controls. In this instance, it is an accordian control. Since I am better at PHP than Ext JS, I was hoping to use these controls. So, it outputs a javascript which breaks my Ext JS panel. My example is simple but I was hoping that if I could get any javascript working that my accordian would work as well.

Thanks,
Scott

14 Dec 2009, 10:52 AM
Hi Scott,

I still don't get it.

I use PHP when developing applications and I have not had the need for this. Are you using PHP to control the view?

scotthathaway
14 Dec 2009, 11:00 AM
The accordian control that I am trying to use has a PHP api. It spits out javascript when it renders. I was not having any success getting Ext JS's accordian working, so I wanted to use this other accordian which I have used in the past. Since it just plugs a javascript into a div tag as it's output, I want to embed a javascript into the html of the Ext JS panel.

Here is the output of the accordian with the php api.

<div class='box'>
<!--KoolSlideMenu version 1.5.0.1 - www.koolphp.net -->
<script type='text/javascript'>if (document.getElementById('__bluearrowKSM')==null){var _head = document.getElementsByTagName('head')[0];var _link = document.createElement('link'); _link.id = '__bluearrowKSM';_link.rel='stylesheet'; _link.href='../common/KoolPHPSuite/KoolControls//KoolSlideMenu/styles/bluearrow/bluearrow.css';_head.appendChild(_link);}</script><div id='ksm' class='bluearrowKSM' style='width:200px;' > <ul class='ksmUL '><li id='company' class='ksmLI ksmLevel0 ksmFirst'><a class='ksmA ksmParent' href='javascript:void 0' ><span class='ksmLeft'> </span><span class='ksmRight'> </span><span class='ksmIn'>Company </span></a><div class='ksmChildBox'><ul class='ksmUL'><li id='about' class='ksmLI ksmFirst'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>About Us </span></a></li><li id='news' class='ksmLI '><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>Company News </span></a></li><li id='contact' class='ksmLI ksmLast'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>Contact us </span></a></li></ul></div></li><li id='products' class='ksmLI ksmLevel0 ksmCollapse '><a class='ksmA ksmParent' href='javascript:void 0' ><span class='ksmLeft'> </span><span class='ksmRight'> </span><span class='ksmIn'>Products </span></a><div class='ksmChildBox'><ul class='ksmUL'><li id='koolajax' class='ksmLI ksmFirst'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>KoolAjax </span></a></li><li id='kooltreeview' class='ksmLI '><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>KoolTreeView </span></a></li><li id='KoolSlideMenu' class='ksmLI ksmLast'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>KoolSlideMenu </span></a></li></ul></div></li><li id='services' class='ksmLI ksmLevel0 ksmCollapse ksmLast'><a class='ksmA ksmParent' href='javascript:void 0' ><span class='ksmLeft'> </span><span class='ksmRight'> </span><span class='ksmIn'>Services </span></a><div class='ksmChildBox'><ul class='ksmUL'><li id='outsourcing' class='ksmLI ksmFirst'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>Out-sourcing </span></a></li><li id='freelancer' class='ksmLI ksmLast'><a class='ksmA ksmChild ' href='javascript:void 0' ><span class='ksmBul'> </span><span class='ksmIn'>Free-lancer </span></a></li></ul></div></li></ul> <input id='ksm.clientState' name='ksm.clientState' type='hidden' /> </div><script type='text/javascript'>if(typeof _libKSM=='undefined'){document.write(unescape("%3Cscript type='text/javascript' src='../common/KoolPHPSuite/KoolControls//KoolSlideMenu/koolslidemenu.php?92daf8712803342f3cf74c4cc4b754f4'%3E %3C/script%3E"));_libKSM=1;}</script><script type='text/javascript'>var ksm; function ksm_init(){ ksm = new KoolSlideMenu('ksm',1,5,1,-1,"{'selectedId':''}");}if (typeof(KoolSlideMenu)=='function'){ksm_init();}else{if(typeof(__KSMInits)=='undefined'){__KSMInits=new Array();} __KSMInits.push(ksm_init);if(typeof(_libKSM)=='undefined'){var _head = document.getElementsByTagName('head')[0];var _script = document.createElement('script'); _script.type='text/javascript'; _script.src='../common/KoolPHPSuite/KoolControls//KoolSlideMenu/koolslidemenu.php?92daf8712803342f3cf74c4cc4b754f4'; _head.appendChild(_script);_libKSM=1;}}</script></div>So I wanted to put this in the html portion of the Ext JS panel.

Thanks,
Scott