在页面加载时出错:Ext Undefined [英] getting error on page load : Ext Undefined
问题描述
我在我的项目中包含.js文件
其中包含消息框的代码
但是在加载时我收到此错误
Ext未定义
请帮忙...
......... ... JS文件代码...........................
< pre lang =Javascript> Ext.require([
' Ext.window.MessageBox',
' Ext.tip。*'
]);
Ext.onReady( function (){
Ext.get(' mb1')。on(' 点击',功能(e){
Ext.MessageBox.confirm(' 确认',' 您确定要吗?要做到这一点?',showResult);
});
Ext.get(' mb2')。on(' click',< span class =code-keyword> function (e){
Ext.MessageBox.prompt(' Name',' 请输入您的姓名:',showResultText);
});
Ext.get(' mb3')。on( ' 点击',功能(e){
Ext.MessageBox.show ({
title:' Address',
msg: 请输入您的地址:',
宽度: 300 ,
按钮:Ext.MessageBox.OKCANCEL,
多行: true ,
fn:showResultText,
animateTarget:' mb3'
});
});
Ext.get(' mb4')。on(' 点击',功能(e){
Ext.MessageBox.show({
title:' Save Changes?',
msg:' 您正在关闭未保存更改的标签。< br />您是否愿意保存更改?',
按钮:Ext.MessageBox.YESNOCANCEL,
fn:showResult,
animateTarget:' mb4',
icon:Ext.MessageBox.QUESTION
});
});
Ext.get(' mb6')。on(' 点击, function (){
Ext.MessageBox.show({
title:' Please wait',
msg:' 正在加载项目......',
progressText:' 初始化...',
宽度: 300 ,
进度: true ,
可关闭: false ,
animateTarget:' mb6'
});
// 这个丑陋的b锁定会造成虚假进度
var f = function (v){
return function (){
if (v == 12 ){
Ext.MessageBox.hide();
Ext.example.msg(' 完成',' 您的假物品已加载!');
} 其他 {
var i = v / 11 跨度>;
Ext.MessageBox.updateProgress(i, Math .round( 100 * i)+ < span class =code-string>' %completed');
}
};
};
for ( var i = 1 ; i< 13 ; i ++){
setTimeout(f(i),i * 500 < /跨度>);
}
});
Ext.get(' mb7')。on(' 点击, function (){
Ext.MessageBox.show({
msg:' 保存您的数据,请稍候......',
progressText:' 保存...',
宽度: 300 ,
等待: true ,
waitConfig:{interval: 200 },
icon:' ext-mb-在msg-box.html下载', // 自定义类
animateTarget :' mb7'
});
setTimeout( function (){
// 这模拟了长时间运行的操作,如数据库保存或XHR调用。
// 在实际代码中,这将是一个回调函数。
Ext.MessageBox.hide();
Ext.example.msg(' 完成',' 你的假货数据已保存!');
}, 8000 );
});
Ext.get(' mb8')。on(' 点击, function (){
Ext.MessageBox.alert(' Status',' 已成功保存更改。',showResult);
});
// 动态添加这些值,以便它们不会在html中进行硬编码
Ext.fly(' info')。dom.value = Ext。 MessageBox.INFO;
Ext.fly(' question')。dom.value = Ext.MessageBox.QUESTION ;
Ext.fly(' warning')。dom.value = Ext.MessageBox.WARNING ;
Ext.fly(' error')。dom.value = Ext.MessageBox.ERROR ;
Ext.get(' mb9')。on(' 点击, function (){
Ext.MessageBox.show({
title:' Icon Support',
msg:' 这是带有图标的消息!',
按钮:Ext。 MessageBox.OK,
animateTarget:' mb9',
fn:showResult,
图标:Ext.get(' icons')。dom.value
});
});
function showResult(btn){
Ext.example.msg(' 按钮单击',' 您单击了{ 0}按钮',btn);
};
function showResultText(btn,text){
Ext.example.msg( ' 按钮单击',' 您点击了{0}按钮并输入文本{1}。',btn,text);
};
});
<%@ Page 语言 = C# AutoEventWireup < span class =code-keyword> =
true CodeBehind = WebForm1.aspx.cs 继承 = MessageBox.WebForm1 %>
&升t; !DOCTYPE html >
< html xmlns = http://www.w3.org/1999/xhtml >
< span class =code-keyword>< head runat = server >
< title > < / title >
< script src = 脚本/JavaScript1.js\"> < / 脚本 >
< / head >
< < span class =code-leadattribute> body onload = javascript:return onload() >
< 表格 id = form1 < span class =code-attribute> runat = server >
< div >
< asp:按钮 runat = 服务器 ID = mb1 文字 = 检查 / >
< / div >
< / form >
< / body >
< / html >
了解HTML文件中包含的参考文件。
如果你没有包括那么添加这样的
你必须在HTML页面中包含这样的引用。
< script < span class =code-attribute> type = text / javascript language = javascript src = ApplicationPath / Script / JS.js > < / script >
检查一下。
http://stackoverflow.com/questions/9242876/extjs-want-to-call-some-co de-after-ext-onready-function [ ^ ]
如果在webserver映射后无法在正确的位置找到与JS文件相关的文件在该位置,您可以在服务器端使用ResolveURl(location_of_js_from_app_root)< %%>标签。这将根据页面的运行时位置解析脚本的正确位置。
否则可能会包含其他必需的文件,但它们不在您的实现中解决方案。
除非有手动修改,否则插件JS文件中不会出现任何错误
i have included .js file in my project
which include code for message box
but on load i'm getting this error
Ext is undefined
please help...
............ JS File code...........................
Ext.require([
'Ext.window.MessageBox',
'Ext.tip.*'
]);
Ext.onReady(function () {
Ext.get('mb1').on('click', function (e) {
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);
});
Ext.get('mb2').on('click', function (e) {
Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
});
Ext.get('mb3').on('click', function (e) {
Ext.MessageBox.show({
title: 'Address',
msg: 'Please enter your address:',
width: 300,
buttons: Ext.MessageBox.OKCANCEL,
multiline: true,
fn: showResultText,
animateTarget: 'mb3'
});
});
Ext.get('mb4').on('click', function (e) {
Ext.MessageBox.show({
title: 'Save Changes?',
msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',
buttons: Ext.MessageBox.YESNOCANCEL,
fn: showResult,
animateTarget: 'mb4',
icon: Ext.MessageBox.QUESTION
});
});
Ext.get('mb6').on('click', function () {
Ext.MessageBox.show({
title: 'Please wait',
msg: 'Loading items...',
progressText: 'Initializing...',
width: 300,
progress: true,
closable: false,
animateTarget: 'mb6'
});
// this hideous block creates the bogus progress
var f = function (v) {
return function () {
if (v == 12) {
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Your fake items were loaded!');
} else {
var i = v / 11;
Ext.MessageBox.updateProgress(i, Math.round(100 * i) + '% completed');
}
};
};
for (var i = 1; i < 13; i++) {
setTimeout(f(i), i * 500);
}
});
Ext.get('mb7').on('click', function () {
Ext.MessageBox.show({
msg: 'Saving your data, please wait...',
progressText: 'Saving...',
width: 300,
wait: true,
waitConfig: { interval: 200 },
icon: 'ext-mb-download', //custom class in msg-box.html
animateTarget: 'mb7'
});
setTimeout(function () {
//This simulates a long-running operation like a database save or XHR call.
//In real code, this would be in a callback function.
Ext.MessageBox.hide();
Ext.example.msg('Done', 'Your fake data was saved!');
}, 8000);
});
Ext.get('mb8').on('click', function () {
Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult);
});
//Add these values dynamically so they aren't hard-coded in the html
Ext.fly('info').dom.value = Ext.MessageBox.INFO;
Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;
Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;
Ext.fly('error').dom.value = Ext.MessageBox.ERROR;
Ext.get('mb9').on('click', function () {
Ext.MessageBox.show({
title: 'Icon Support',
msg: 'Here is a message with an icon!',
buttons: Ext.MessageBox.OK,
animateTarget: 'mb9',
fn: showResult,
icon: Ext.get('icons').dom.value
});
});
function showResult(btn) {
Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
};
function showResultText(btn, text) {
Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);
};
});
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="MessageBox.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/JavaScript1.js"></script>
</head>
<body onload="javascript:return onload()">
<form id="form1" runat="server">
<div>
<asp:Button runat="server" ID="mb1" Text="Check" />
</div>
</form>
</body>
</html>
Find out the refrence for the JS file is included in the HTML page.
If you have not included then add like this
You must include the reference like this in your HTML Page. <script type="text/javascript" language="javascript" src="ApplicationPath/Script/JS.js"></script>
Check this.
http://stackoverflow.com/questions/9242876/extjs-want-to-call-some-code-after-ext-onready-function[^]
If its related to JS file not been able to be found at the correct location after the webserver maps the location, you can use ResolveURl(location_of_js_from_app_root) within server side <% %> tags. This will resolve the script's correct location as per the runtime location of the page.
Else there can be other required files to be included but they are not present in your implemented solution.
There will not be any error within the pluggin JS file unless there are manual modificatons
这篇关于在页面加载时出错:Ext Undefined的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!