2

我在两个不同的位置有两个 js 页面(Source.js 和 Target.js),现在我要做的就是当用户单击源页面的下拉列表时,它将用户重定向到目标页面,反之亦然。我正在为您提供所有位置和所有内容的确切编码,我只想知道如何从一页切换到第二页。

Source.js 编码

var SourceSc = function() {
var that = {};
var _view = null;
var _childPanel = "#content";
var _sourceDlgMgrC = null;
var BEGIN = "BEGIN";
var STARTING = "STARTING";
var END = "END";
var TARGET = "TARGET";  
var _state = BEGIN;
that.create = function(parent, panel) {

    _parent = parent;
    _panel = panel;
    _transition(STARTING);
};
that.destroy = function() {
    _transition(END);
};
that.eventTargetLanguageView = function() {
    _transition(TARGET_LANGUAGE_VIEW);
};
var _transition = function(newState) {
    _state = newState;
    switch(_state) {                
        case STARTING: _enterStarting(); break;
            case TARGET: _enterTargetDlg(); break;
        case END: _enterEnd(); break;
    }
};
var _enterStarting = function() {
    modelMgr.loadInclude('code/app/sc/LoggedIn/sc/Source/c/SourceDlgMgrC.js', function() {
        modelMgr.getHTML('code/app/sc/LoggedIn/sc/Source/Source.html', function(html) {
            _sourceDlgMgrC = SourceDlgMgrC();
            _sourceDlgMgrC.create(_childPanel);
            var req = {};
            var fnSuccess = function(res) {
                _view = SourceV();
                _view.create(that, _panel, html, res);                  
            };              
        });
    });
};  
var _enterTargetDlg = function() 
{
//now what i have to write here, to load target page
};
var _enterEnd = function() {
     //coding of destroy    
};  
return that;};
var SourceV = function() {
var that = {};

var _sc = null;
var _panel = null;

that.create = function(sc, panel, html, res) {
    _sc = sc;
    _panel = panel;
    that.layoutUi(html);
    that.bindEvents();  
};  
that.layoutUi = function(html) {

    $(_panel).html(html);       
};
that.bindEvents = function() {

    $('#viewList').change(_sc.eventTargetLanguageView);
};
that.destroy = function() {
    $(_panel).html('');
    _panel = null;
    _sc = null;
};
return that; };

我可以发布 source.html 完整编码,但我想这会少用所以我只会发布下拉列表编码

    <select id = "viewList" class="fl width160">
            <option>Source</option>
            <option>Target</option>
        </select>

现在目标页面的编码也完全相同,但 Target.js 的位置是“code/app/sc/LoggedIn/sc/Target/Target.js”

4

1 回答 1

1

试试这个......(仅作为示例)

 codeLoadingMgr.loadInclude( path + '/AdminSc.js', function() {
 _adminSc = AdminSc();
  _adminSc.create(that, path, _childPanel,_selectedAdminTab, _programId); 
   });
于 2012-06-13T06:07:09.553 回答