这可能是一个完全愚蠢的问题,但我刚刚开始使用 Atom shell。
我有index.html
一个登录表单。我像这样准备好文档中的 jquery 表单验证:
$(function() {
$('#login-form').validate();
});
该脚本在正文结束之前加载,如下所示:
<script src="global/js/dom-bootstrap.js"></script>
当我使用 Atom Shell 运行页面时,表单会正确显示,并且验证部分有效。它不提交表单,但不显示任何验证。然后,当我在同一页面上提交表单(例如,重新加载页面)时,一切正常!
包括 Bootstrap 的tab.js
. 起初它不起作用,但在重新加载页面后它工作得很好。
我究竟做错了什么?
这是我的main.js
(基于 Github 的 Atom Shell 示例):
var app = require('app'); // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
// Report crashes to our server.
require('crash-reporter').start();
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;
// Quit when all windows are closed.
app.on('window-all-closed', function() {
if (process.platform != 'darwin')
app.quit();
});
// This method will be called when atom-shell has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({
icon : 'global/images/logo.png',
transparent : true,
frame : false,
"min-width" : 520,
"min-height" : 850,
fullscreen : true,
resize : true,
"use-content-size" : true
});
mainWindow.webContents.on('did-finish-load', function() {
});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/index.html');
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
});