Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8390385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:58:16+00:00 2026-06-09T18:58:16+00:00

In my project I create modules for each webpage and add to a base

  • 0

In my project I create modules for each webpage and add to a base object called View:

App.js

var View = (function()  {

    var View  = function()  {
        this.attributes = {
            baseUrl : '',
            urls : {}
        };
    };

    View.prototype.setUrl = function(url)   {
        this.attributes.baseUrl = url;
    };

    View.prototype.getUrl = function()  {
        return this.attributes.baseUrl;
    };

    return new View();

})();

SearchView.js

var View = View || {};

var SearchView = View.SearchView = (function()  {

    var Private = {
        search : function(url)  {},
        loadSearchResult : function()   {},
        clearSearchForm : function()    {}
    };

    Private.search = function(url)  {
        ajax(url,...);
        this.loadSearchResult();
    };

    var SearchView = function() {
        this.settings = {};
    };

    SearchView.prototype.loadEventBindind = function()  {
        $(document)

        .on('click','#search-button', function()    {
            Private.search(View.baseUrl);
        })

        .on('click','#reset-search', function() {
            Private.clearSearchForm();
        });
    };

    return new SearchView();

})();

search.html

<script type="text/javascript" src="media/scripts/Modules/App.js"></script>
<script type="text/javascript" src="media/scripts/View/SearchView.js"></script>
<script type="text/javascript">
    View.setUrl('http://www.set.com/');
    View.SearchView.loadEventBindings();
</script>

This code works properly in Chrome and Firefox, but throws an error in IE:

‘View.SearchView‘ is null or not an object

Does IE not support this way of creating objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:58:18+00:00Added an answer on June 9, 2026 at 6:58 pm

    There are few things you should do:

    You have a weak point in that your App.js script could overwrite View object created by SearchView.js.

    • Don’t use one variable as both namespace and class. It’s counter intuitive.
    • If you’re already writing singletons, there is no need to use prototype pattern, although there’s nothing wrong with it. You won’t save any memory though.

    If you’re sticking your guns to using View as class and namespace, make changes like this to prevent View being overwritten.

    var View = View || {};
    var ViewTmp;
    $.extend(ViewTmp = (function()  {
    
        var View  = function()  {
        ...
      ...
    })(), View);
    View = ViewTmp;
    

    This script assumes that you are using jQuery (because of $.extend method).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a new View (LogView) in Infrastructure.Module project. This view will be used
In ZF you create a project by running this command: zf create project MyProjectName
I have a Create View page in my MVC3 project to create instances of
I've been assigned a project to create a file storage service on Google App
Hi I am trying to create a multi-modules project in eclipse with m2eclipse. I
I am working on a project that uses MPI to create parallel processes, each
I am using soapUI maven plugin to create a multi-module maven-soapUi project. I have
how to create project for native c++ executable in visual studio 2012. In previous
I have a project to create a program, which prevents the user from escaping
we are using wix project to create msi. We were trying to do major

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.