PDA

View Full Version : extjs only works in Chrome?



BP64531
30 Aug 2009, 12:37 AM
hi, i just trying to pop up the MessageBox, below is the code :


<html>
<head>
<title>DUMMY</title>
</head>
<link rel="stylesheet" type="text/css" href="<?=base_url()?>ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<?=base_url()?>ext/examples/shared/examples.css" />
<script type="text/javascript" language="javascript" src="<?=base_url()?>ext/adapter/ext/ext-base.js" />
<script type="text/javascript" language="javascript" src="<?=base_url()?>ext/ext-all.js" />

<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '<?=base_url()?>ext/resources/images/default/s.gif';

Ext.onReady(function(){
Ext.get('foo').on('click', function(e){
Ext.MessageBox.confirm('Confirm', 'holaaa');
});
});
</script>
<body>
<button id="foo">haha</button>
</body>
</html>

I try this in IE8 and FireFox 3, but there is nothing happen when i click the button foo. Then i try this in google chrome, it's works!! Please help me, I'm very confuse with these.

sorry for my bad English:D

Mike Robinson
30 Aug 2009, 5:41 AM
The paragraph that you probably overlooked in the documentation (I did too!) is this one:
---
Note that the MessageBox is asynchronous. Unlike a regular JavaScript alert (which will halt browser execution), showing a MessageBox will not cause the code to stop. For this reason, if you have code that should only run after some user feedback from the MessageBox, you must use a callback function (see the function parameter for show (http://www.extjs.com/forum/../deploy/dev/docs/output/Ext.MessageBox.html#Ext.MessageBox-show) for more details).

---

The dialog-box window appears, but your code "keeps right on going!" If you want something to happen when the button is clicked, you must write an event handler! No, this is not "obvious" or "what you were expecting."
---
The bit about "it only works in Chrome" is, I believe, what we call "a red herring."

BP64531
31 Aug 2009, 2:57 AM
Now it works in IE and Firefox. I just changed the script tag.
I write <script type="text/javascript" ..... /> now i changed it to <script type="text/javascript ....></script>

it's weird:-/

Animal
31 Aug 2009, 4:17 AM
It's not weird.

HTML !== XML

steffenk
31 Aug 2009, 4:35 AM
there are some traps in HTML, i also had this issue once and it's strange to me that script shorttag isn't read by some browsers.

The other was with css inclusion when using a title attribute - it won't be loaded in most cases.

paulcrowder
31 Aug 2009, 9:04 AM
The easy way to know when an HTML tag can be self-closed using " />" is if you can answer "No" to the question "can content ever exist between the opening and closing tags of this element?" Elements like SCRIPT, DIV, P, etc. can have content between their opening and closing tag, so they cannot be self-closed.