What could be causing the HTML element to be invisible on Internet Explorer?

I am currently working on my angularjs project.

One of the features I have implemented is an HTML view that switches between display mode and edit mode when a button is clicked.

To style this functionality, I created a CSS class called edit-mode.

You can check out the live version on Plunker.

Below is the code for my view:

<form class="form-horizontal form-sm">
  <div ng-class="{'edit-mode':editor.edit}">

    <div class="form-group">
      <div class="col-xs-8">
        <span class="view">{{ma.inspection}}</span>
        <textarea cols="20" rows="2" my-maxlength="5" ng-model="ma.inspection" class="form-control edit"></textarea>
      </div>
    </div>
    <br/>
    <input type="button" ng-click="editor.edit = false" value="Display mode">
    <input type="button" ng-click="editor.edit = true" value="Edit mode">

  </div>
</form>

Here is the controller code:

var app = angular.module('myApp', ['ngAnimate']);
app.controller('MyApp', [function() {
  var self = this;
  this.inspection = "Click on the button to change modes";

}]);

And here is the CSS code I used:

.edit, input[type=file].edit {

    display: none;
}

.edit-mode {
    .view {
        display: none;
        background-color:red;
    }

    .edit, input[type=file].edit {
        display: initial;
    }
}

While this code works perfectly in Chrome, I encountered some issues with Internet Explorer (specifically IE 11) where the textarea and select elements are not displayed properly. Does anyone have any ideas on how to fix this and make it work seamlessly across all browsers?

Answer №1

initial keyword may not function properly on IE. This is in line with the typical behavior of Internet Explorer where certain things do not work as expected. However, to resolve this issue, ensure that you use inline for form elements.

 display: inline

For textarea elements:

 display: inline-block

Here is the final code snippet:

.edit-mode {
    .view {
        display: none;
        background-color:red;
    }

    .edit, input[type=file].edit {
        display: inline-block;
    }
}

Answer №3

As reiterated in all the previous responses, it is important to note that display:initial; does not have support in Internet Explorer. Therefore, the optimal approach for achieving cross-browser compatibility with AngularJS is to leverage ng-show for dynamically hiding elements rather than relying solely on CSS.

I have personally conducted tests confirming the functionality of this method on Internet Explorer 11 without utilizing any specific classes.

<body>
  <link href="style.css" rel="stylesheet" />
  <div ng-controller="MyApp as ma">

    <form class="form-horizontal form-sm">
      <!--<div ng-class="{'edit-mode':editor.edit}">-->

        <div class="form-group">
          <div class="col-xs-8">
            <span ng-init="editor.edit=false" ng-show="editor.edit == false">{{ma.inspection}}</span>
            <textarea cols="20" rows="2" ng-show="editor.edit == true" my-maxlength="5" ng-model="ma.inspection" class="form-control"></textarea>
          </div>
        </div>
        <br/>
        <input type="button" ng-click="editor.edit = false" value="Display mode">
        <input type="button" ng-click="editor.edit = true" value="Edit mode">

      <!--</div>-->
    </form>



  </div>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
  <script>
    var app = angular.module('myApp', ['ngAnimate']);
    app.controller('MyApp', [function() {

      // default 
      editor = {};
      editor.edit = false;

      var self = this;
      this.inspection = "Click on button to change mode!";

    }]);
  </script>
</body>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Styles are not being applied properly to mat-expansion-panel-header within a child component in CSS

One of my components utilizes MatExpansionPanel to showcase a collection of products. I have included some CSS code to conceal the overflow of each product's description. To view the current appearance, please refer to this stackblitz. In an attempt ...

I am unable to display the service response in the Angular component

I'm facing an issue with displaying data in an angular component from a service. The process from the service to the component seems fine, but when I try to use the variable in HTML, it doesn't show the result. For this project, I am using the M ...

Rendering ng-include before setting the source

Is there a way to prevent the ng-include directive from trying to render before a value on scope is set? Consider the following example: <ng-include src="'./lib/templates/' + $parent.currentEditable.editTemplate"></ng-include> It s ...

What could be the reason that ngModel is failing to execute $setViewValue(...) when called

I am developing a directive that requires an isolated scope, but I also need to bind it to the parent scope using ngModel. However, I am facing an issue where the value of the parent's scope is not being updated. Below is the markup: <form name= ...

The function client.guilds.find cannot be located

Hey there! I've been tasked with working on a Discord bot that requires several dependencies to function properly. I've installed the necessary dependencies and attempted to run the bot using 'forever -o out.log bot.js'. However, I enc ...

Data is not being stored in the MongoDB Model/Schema as expected

I'm encountering an issue with my MongoDB database. It appears to not be receiving the data I am attempting to send to it, resulting in an empty database despite everything else functioning smoothly. The application I'm working on involves scrap ...

Exploring the implementation of method decorators that instantiate objects within Typescript

Currently, I have been working on a lambda project and utilizing the lambda-api package for development. As part of this process, I have implemented decorators named Get and Post to facilitate mapping routes within the lambda api object. These decorators e ...

Tips on saving additional parameters in an API URL with AngularJS

Here is my AngularJS function code: $scope.cardcall = function (cardtype) { $scope.cityname=cityname; $http({method: 'GET',url: '/api/v1/asasas&filterBy=cardNames&filterByValue='+cardtype.key}).success(funct ...

What are the steps for editing and preserving a logo with an 8-bit indexed color palette?

After purchasing a RE/MAX franchise, I now need to make edits to the official logo found on remax.com using Adobe Photoshop. However, I have encountered a problem when trying to edit their logo in Photoshop. When I open their PNG logo, the layer appears d ...

Autocomplete for Converting Postal Codes to Cities

I'm currently working on a project that involves two input fields, as shown below: <div class="form-group{{ $errors->has('plz') ? ' has-error' : '' }}"> <label for="plz" class ...

Share an image using a subdomain in Express.js

Suppose I have the following code for testing on a local environment. sendImage: async function(req, res) { console.log(req.hostname); var filepath = path.join(__dirname, '../../img/uploads/' + req.params.year + '/' + req.para ...

The challenge of removing an event listener

There are three Div elements with a box appearance. When the user clicks on any div, a copy of that div will be added to the end. The original clicked div will no longer be clickable, but the new div will be. This process can repeat indefinitely. I attemp ...

CSS problem: Footer encroaching on the content above

For more information, please visit this link When the window is minimized, the footer overlaps the content above it. Despite spending hours trying to fix this issue, I have not been successful. View when maximized: here View when minimized: here Even af ...

Utilizing the power of d3.js within Angular 4

Currently, I have successfully implemented code to draw a polygon using the mouse in a normal JavaScript file. Now, I am looking to replicate the same functionality in my TypeScript file. Below is an excerpt from my d3.js file: //D3.JS VERSION 3 //------ ...

Javascript is not being executed on Firefox Mobile

I need help with running my local website on the Firefox mobile emulator. Although I can see the welcome page, I am unable to access the website because it requires the execution of some JavaScript. Can someone please advise me on how to enable this featur ...

Ag Grid does not allow filtering on columns that have been grouped together

When looking at the image below, I notice that when I group by a column and then apply a filter, it shows '(Select All)' and '(blanks)' in the dropdown instead of the actual values from the grouped column such as '(12/01/2016)&apos ...

Debugging with Webstorm in node.js may not navigate to breakpoints as expected

Currently utilizing the angular-fullstack generator alongside Webstorm 10. The setup for node.js remote debug is as follows: localhost: 127.0.0.1 port: 5858 After inputting 'grunt serve:debug': Debugger listening on port 5858 Node Inspecto ...

Incorporating server-side HTML content into a div using Angular 2

I have a series of HTML files stored on my server. Examples include: Now, I am attempting to include these files into a <div> in my Angular 2 v4 app. For instance: component.ts public changePage(name: string) { switch (name) { case 'int ...

What is the process for creating a default button in Ionic framework?

Recently, I developed an app that includes a survey page. Each question in the survey has two buttons for the user to select: Yes or No. However, as a newcomer to using Ionic, I encountered an issue after building the code and checking the output. One of ...

Ionic utilized the $http service and was unexpectedly triggered two times

$scope.login = function(email,password){ $http({ method: 'POST', url: 'http://example.com/login', headers: { 'owner': $rootScope.secret }, data: {email:email, password:password } }).then(function successCallback(response) { co ...