CSS style shows after refresh and then goes invisible with Knockout












1














So I have a new notification style ring and green circle with unread notifications in it this circle only is visible when you have new notifications.New 1 Notification



when page is refreshed even if you dont have a notification the circle is visible for a second and then goes invisible



enter image description here



If there is a new notification still when refreshed circle shows up empty or with zero and then goes invisible and then with correct number



HTML:



<div class="bell">
<div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
</div>


CSS:



.unseen-notification-show {
content: '';
display: block !important;
position: absolute;
top: -10px;
right: -8px;
width: 17px;
height: 17px;
border: 1px solid #ffffff;
background-color: #8cdb16;
border-radius: 8px;
cursor: pointer;
z-index: 3;
color: white;
text-align: center;
line-height: 15px;
font-size: 11px;
font-family: 'Times New Roman', Times, serif;
}

self.searchModel = new AuthorizedSearchViewModel();
self.Header = ko.observable(new HeaderModel());
self.UnSeenMessagesCount = ko.observable(0);
self.Messages = ko.observableArray();
self.CanShowRemindProfile = ko.observable(false);
self.Remind = ko.observable(new RemindModel());

self.LoadUserInformation = function () {
$.post('/User/GetUserInfoForDashboardHeader',
function (response) {
InitTawkChat(response);
self.Header(new HeaderModel(response));

if ($('#accountId').length > 0) {
$('#accountId').html(response.accountId);
}

}, "json").done(function () { console.warn("loaderOff"); });
};

self.GetRemindProfile = function () {
self.CanShowRemindProfile(false);
$.post('/User/GetRemindProfile', function (result) {
if (result) {
self.CanShowRemindProfile(true);
self.Remind(new RemindModel(result));
}
});
};

self.GetMessages = function () {
$.post('/Messages/GetAll', {
page: 1,
pageSize: 4
}, function (result) {
var notifications = ;

_.map(result.Notifications, function (item) {
notifications.push(new MessageModel(item));
});

self.Messages(notifications);
self.UnSeenMessagesCount(result.UnseenNotifications);
});
};









share|improve this question
























  • try using position:relative;
    – Selvam
    Nov 20 '18 at 9:24
















1














So I have a new notification style ring and green circle with unread notifications in it this circle only is visible when you have new notifications.New 1 Notification



when page is refreshed even if you dont have a notification the circle is visible for a second and then goes invisible



enter image description here



If there is a new notification still when refreshed circle shows up empty or with zero and then goes invisible and then with correct number



HTML:



<div class="bell">
<div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
</div>


CSS:



.unseen-notification-show {
content: '';
display: block !important;
position: absolute;
top: -10px;
right: -8px;
width: 17px;
height: 17px;
border: 1px solid #ffffff;
background-color: #8cdb16;
border-radius: 8px;
cursor: pointer;
z-index: 3;
color: white;
text-align: center;
line-height: 15px;
font-size: 11px;
font-family: 'Times New Roman', Times, serif;
}

self.searchModel = new AuthorizedSearchViewModel();
self.Header = ko.observable(new HeaderModel());
self.UnSeenMessagesCount = ko.observable(0);
self.Messages = ko.observableArray();
self.CanShowRemindProfile = ko.observable(false);
self.Remind = ko.observable(new RemindModel());

self.LoadUserInformation = function () {
$.post('/User/GetUserInfoForDashboardHeader',
function (response) {
InitTawkChat(response);
self.Header(new HeaderModel(response));

if ($('#accountId').length > 0) {
$('#accountId').html(response.accountId);
}

}, "json").done(function () { console.warn("loaderOff"); });
};

self.GetRemindProfile = function () {
self.CanShowRemindProfile(false);
$.post('/User/GetRemindProfile', function (result) {
if (result) {
self.CanShowRemindProfile(true);
self.Remind(new RemindModel(result));
}
});
};

self.GetMessages = function () {
$.post('/Messages/GetAll', {
page: 1,
pageSize: 4
}, function (result) {
var notifications = ;

_.map(result.Notifications, function (item) {
notifications.push(new MessageModel(item));
});

self.Messages(notifications);
self.UnSeenMessagesCount(result.UnseenNotifications);
});
};









share|improve this question
























  • try using position:relative;
    – Selvam
    Nov 20 '18 at 9:24














1












1








1







So I have a new notification style ring and green circle with unread notifications in it this circle only is visible when you have new notifications.New 1 Notification



when page is refreshed even if you dont have a notification the circle is visible for a second and then goes invisible



enter image description here



If there is a new notification still when refreshed circle shows up empty or with zero and then goes invisible and then with correct number



HTML:



<div class="bell">
<div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
</div>


CSS:



.unseen-notification-show {
content: '';
display: block !important;
position: absolute;
top: -10px;
right: -8px;
width: 17px;
height: 17px;
border: 1px solid #ffffff;
background-color: #8cdb16;
border-radius: 8px;
cursor: pointer;
z-index: 3;
color: white;
text-align: center;
line-height: 15px;
font-size: 11px;
font-family: 'Times New Roman', Times, serif;
}

self.searchModel = new AuthorizedSearchViewModel();
self.Header = ko.observable(new HeaderModel());
self.UnSeenMessagesCount = ko.observable(0);
self.Messages = ko.observableArray();
self.CanShowRemindProfile = ko.observable(false);
self.Remind = ko.observable(new RemindModel());

self.LoadUserInformation = function () {
$.post('/User/GetUserInfoForDashboardHeader',
function (response) {
InitTawkChat(response);
self.Header(new HeaderModel(response));

if ($('#accountId').length > 0) {
$('#accountId').html(response.accountId);
}

}, "json").done(function () { console.warn("loaderOff"); });
};

self.GetRemindProfile = function () {
self.CanShowRemindProfile(false);
$.post('/User/GetRemindProfile', function (result) {
if (result) {
self.CanShowRemindProfile(true);
self.Remind(new RemindModel(result));
}
});
};

self.GetMessages = function () {
$.post('/Messages/GetAll', {
page: 1,
pageSize: 4
}, function (result) {
var notifications = ;

_.map(result.Notifications, function (item) {
notifications.push(new MessageModel(item));
});

self.Messages(notifications);
self.UnSeenMessagesCount(result.UnseenNotifications);
});
};









share|improve this question















So I have a new notification style ring and green circle with unread notifications in it this circle only is visible when you have new notifications.New 1 Notification



when page is refreshed even if you dont have a notification the circle is visible for a second and then goes invisible



enter image description here



If there is a new notification still when refreshed circle shows up empty or with zero and then goes invisible and then with correct number



HTML:



<div class="bell">
<div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
</div>


CSS:



.unseen-notification-show {
content: '';
display: block !important;
position: absolute;
top: -10px;
right: -8px;
width: 17px;
height: 17px;
border: 1px solid #ffffff;
background-color: #8cdb16;
border-radius: 8px;
cursor: pointer;
z-index: 3;
color: white;
text-align: center;
line-height: 15px;
font-size: 11px;
font-family: 'Times New Roman', Times, serif;
}

self.searchModel = new AuthorizedSearchViewModel();
self.Header = ko.observable(new HeaderModel());
self.UnSeenMessagesCount = ko.observable(0);
self.Messages = ko.observableArray();
self.CanShowRemindProfile = ko.observable(false);
self.Remind = ko.observable(new RemindModel());

self.LoadUserInformation = function () {
$.post('/User/GetUserInfoForDashboardHeader',
function (response) {
InitTawkChat(response);
self.Header(new HeaderModel(response));

if ($('#accountId').length > 0) {
$('#accountId').html(response.accountId);
}

}, "json").done(function () { console.warn("loaderOff"); });
};

self.GetRemindProfile = function () {
self.CanShowRemindProfile(false);
$.post('/User/GetRemindProfile', function (result) {
if (result) {
self.CanShowRemindProfile(true);
self.Remind(new RemindModel(result));
}
});
};

self.GetMessages = function () {
$.post('/Messages/GetAll', {
page: 1,
pageSize: 4
}, function (result) {
var notifications = ;

_.map(result.Notifications, function (item) {
notifications.push(new MessageModel(item));
});

self.Messages(notifications);
self.UnSeenMessagesCount(result.UnseenNotifications);
});
};






javascript html css knockout.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 14:07

























asked Nov 20 '18 at 9:16









George Krialashvili

197




197












  • try using position:relative;
    – Selvam
    Nov 20 '18 at 9:24


















  • try using position:relative;
    – Selvam
    Nov 20 '18 at 9:24
















try using position:relative;
– Selvam
Nov 20 '18 at 9:24




try using position:relative;
– Selvam
Nov 20 '18 at 9:24












3 Answers
3






active

oldest

votes


















2














Remove !important from display property in your css and let knockout inline handle display.






function viewModel(){
var self = this;
self.UnSeenMessagesCount = ko.observable();

self.initData = function(){
//dummy setTimeout for your ajax get.
setTimeout(function(){
self.UnSeenMessagesCount(4);
},1000);
}

}

var vm = new viewModel();
vm.initData();

ko.applyBindings(vm);

.unseen-notification-show {
content: '';
display: block;
position: absolute;

width: 17px;
height: 17px;
border: 1px solid #ffffff;
background-color: #8cdb16;
border-radius: 8px;
cursor: pointer;
z-index: 3;
color: white;
text-align: center;
line-height: 15px;
font-size: 11px;
font-family: 'Times New Roman', Times, serif;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div class="bell">
<div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
</div>








share|improve this answer































    1














    Sounds like some loading issues. Try moving your css from being loaded in the top of the HTML, to be loaded in the bottom/footer.



    What you want to do, is to hide the circle until the result is loaded (either 0 or 1,2,3,4.. and so on. Depending on the number of notifications).



    In your div you got this line style="display:none"> which hides the circle. Thats good!



    Now you should make sure that the style for .unseen-notification-show which contains display: block !important; that shows the circle - Should not be run before the calculation of the number to show is done.



    One way could be to place the file that loads your css to the bottom of the HTML (like moving your <link rel="stylesheet" href="test.css" />). Or another way is to only use css for the hiding and then use javascript/jQuery for showing the cirle.



    If this didn't help - then please provide the code you use to generate the number.






    share|improve this answer





















    • I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
      – George Krialashvili
      Nov 20 '18 at 14:10










    • What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
      – JonasB
      Nov 20 '18 at 14:26












    • if I remove visible it will just stay displayed
      – George Krialashvili
      Nov 20 '18 at 14:58










    • Ok. I don’t have a solution then :(
      – JonasB
      Nov 20 '18 at 17:55



















    0














    I think the issue is due to
    self.UnSeenMessagesCount = ko.observable(0);
    so when your modal is getting created it is initialized with value 0. So when you refresh the page initially it is 0 but when self.getMessage is called it updates your value.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389705%2fcss-style-shows-after-refresh-and-then-goes-invisible-with-knockout%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      Remove !important from display property in your css and let knockout inline handle display.






      function viewModel(){
      var self = this;
      self.UnSeenMessagesCount = ko.observable();

      self.initData = function(){
      //dummy setTimeout for your ajax get.
      setTimeout(function(){
      self.UnSeenMessagesCount(4);
      },1000);
      }

      }

      var vm = new viewModel();
      vm.initData();

      ko.applyBindings(vm);

      .unseen-notification-show {
      content: '';
      display: block;
      position: absolute;

      width: 17px;
      height: 17px;
      border: 1px solid #ffffff;
      background-color: #8cdb16;
      border-radius: 8px;
      cursor: pointer;
      z-index: 3;
      color: white;
      text-align: center;
      line-height: 15px;
      font-size: 11px;
      font-family: 'Times New Roman', Times, serif;
      }

      <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
      <div class="bell">
      <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
      </div>








      share|improve this answer




























        2














        Remove !important from display property in your css and let knockout inline handle display.






        function viewModel(){
        var self = this;
        self.UnSeenMessagesCount = ko.observable();

        self.initData = function(){
        //dummy setTimeout for your ajax get.
        setTimeout(function(){
        self.UnSeenMessagesCount(4);
        },1000);
        }

        }

        var vm = new viewModel();
        vm.initData();

        ko.applyBindings(vm);

        .unseen-notification-show {
        content: '';
        display: block;
        position: absolute;

        width: 17px;
        height: 17px;
        border: 1px solid #ffffff;
        background-color: #8cdb16;
        border-radius: 8px;
        cursor: pointer;
        z-index: 3;
        color: white;
        text-align: center;
        line-height: 15px;
        font-size: 11px;
        font-family: 'Times New Roman', Times, serif;
        }

        <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
        <div class="bell">
        <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
        </div>








        share|improve this answer


























          2












          2








          2






          Remove !important from display property in your css and let knockout inline handle display.






          function viewModel(){
          var self = this;
          self.UnSeenMessagesCount = ko.observable();

          self.initData = function(){
          //dummy setTimeout for your ajax get.
          setTimeout(function(){
          self.UnSeenMessagesCount(4);
          },1000);
          }

          }

          var vm = new viewModel();
          vm.initData();

          ko.applyBindings(vm);

          .unseen-notification-show {
          content: '';
          display: block;
          position: absolute;

          width: 17px;
          height: 17px;
          border: 1px solid #ffffff;
          background-color: #8cdb16;
          border-radius: 8px;
          cursor: pointer;
          z-index: 3;
          color: white;
          text-align: center;
          line-height: 15px;
          font-size: 11px;
          font-family: 'Times New Roman', Times, serif;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
          <div class="bell">
          <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
          </div>








          share|improve this answer














          Remove !important from display property in your css and let knockout inline handle display.






          function viewModel(){
          var self = this;
          self.UnSeenMessagesCount = ko.observable();

          self.initData = function(){
          //dummy setTimeout for your ajax get.
          setTimeout(function(){
          self.UnSeenMessagesCount(4);
          },1000);
          }

          }

          var vm = new viewModel();
          vm.initData();

          ko.applyBindings(vm);

          .unseen-notification-show {
          content: '';
          display: block;
          position: absolute;

          width: 17px;
          height: 17px;
          border: 1px solid #ffffff;
          background-color: #8cdb16;
          border-radius: 8px;
          cursor: pointer;
          z-index: 3;
          color: white;
          text-align: center;
          line-height: 15px;
          font-size: 11px;
          font-family: 'Times New Roman', Times, serif;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
          <div class="bell">
          <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
          </div>








          function viewModel(){
          var self = this;
          self.UnSeenMessagesCount = ko.observable();

          self.initData = function(){
          //dummy setTimeout for your ajax get.
          setTimeout(function(){
          self.UnSeenMessagesCount(4);
          },1000);
          }

          }

          var vm = new viewModel();
          vm.initData();

          ko.applyBindings(vm);

          .unseen-notification-show {
          content: '';
          display: block;
          position: absolute;

          width: 17px;
          height: 17px;
          border: 1px solid #ffffff;
          background-color: #8cdb16;
          border-radius: 8px;
          cursor: pointer;
          z-index: 3;
          color: white;
          text-align: center;
          line-height: 15px;
          font-size: 11px;
          font-family: 'Times New Roman', Times, serif;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
          <div class="bell">
          <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
          </div>





          function viewModel(){
          var self = this;
          self.UnSeenMessagesCount = ko.observable();

          self.initData = function(){
          //dummy setTimeout for your ajax get.
          setTimeout(function(){
          self.UnSeenMessagesCount(4);
          },1000);
          }

          }

          var vm = new viewModel();
          vm.initData();

          ko.applyBindings(vm);

          .unseen-notification-show {
          content: '';
          display: block;
          position: absolute;

          width: 17px;
          height: 17px;
          border: 1px solid #ffffff;
          background-color: #8cdb16;
          border-radius: 8px;
          cursor: pointer;
          z-index: 3;
          color: white;
          text-align: center;
          line-height: 15px;
          font-size: 11px;
          font-family: 'Times New Roman', Times, serif;
          }

          <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
          <div class="bell">
          <div class="unseen-notification-show" data-bind="visible: UnSeenMessagesCount() > 0, text: UnSeenMessagesCount()" style="display:none"></div>
          </div>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 '18 at 20:26

























          answered Nov 20 '18 at 20:18









          Amit Bhoyar

          38410




          38410

























              1














              Sounds like some loading issues. Try moving your css from being loaded in the top of the HTML, to be loaded in the bottom/footer.



              What you want to do, is to hide the circle until the result is loaded (either 0 or 1,2,3,4.. and so on. Depending on the number of notifications).



              In your div you got this line style="display:none"> which hides the circle. Thats good!



              Now you should make sure that the style for .unseen-notification-show which contains display: block !important; that shows the circle - Should not be run before the calculation of the number to show is done.



              One way could be to place the file that loads your css to the bottom of the HTML (like moving your <link rel="stylesheet" href="test.css" />). Or another way is to only use css for the hiding and then use javascript/jQuery for showing the cirle.



              If this didn't help - then please provide the code you use to generate the number.






              share|improve this answer





















              • I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
                – George Krialashvili
                Nov 20 '18 at 14:10










              • What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
                – JonasB
                Nov 20 '18 at 14:26












              • if I remove visible it will just stay displayed
                – George Krialashvili
                Nov 20 '18 at 14:58










              • Ok. I don’t have a solution then :(
                – JonasB
                Nov 20 '18 at 17:55
















              1














              Sounds like some loading issues. Try moving your css from being loaded in the top of the HTML, to be loaded in the bottom/footer.



              What you want to do, is to hide the circle until the result is loaded (either 0 or 1,2,3,4.. and so on. Depending on the number of notifications).



              In your div you got this line style="display:none"> which hides the circle. Thats good!



              Now you should make sure that the style for .unseen-notification-show which contains display: block !important; that shows the circle - Should not be run before the calculation of the number to show is done.



              One way could be to place the file that loads your css to the bottom of the HTML (like moving your <link rel="stylesheet" href="test.css" />). Or another way is to only use css for the hiding and then use javascript/jQuery for showing the cirle.



              If this didn't help - then please provide the code you use to generate the number.






              share|improve this answer





















              • I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
                – George Krialashvili
                Nov 20 '18 at 14:10










              • What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
                – JonasB
                Nov 20 '18 at 14:26












              • if I remove visible it will just stay displayed
                – George Krialashvili
                Nov 20 '18 at 14:58










              • Ok. I don’t have a solution then :(
                – JonasB
                Nov 20 '18 at 17:55














              1












              1








              1






              Sounds like some loading issues. Try moving your css from being loaded in the top of the HTML, to be loaded in the bottom/footer.



              What you want to do, is to hide the circle until the result is loaded (either 0 or 1,2,3,4.. and so on. Depending on the number of notifications).



              In your div you got this line style="display:none"> which hides the circle. Thats good!



              Now you should make sure that the style for .unseen-notification-show which contains display: block !important; that shows the circle - Should not be run before the calculation of the number to show is done.



              One way could be to place the file that loads your css to the bottom of the HTML (like moving your <link rel="stylesheet" href="test.css" />). Or another way is to only use css for the hiding and then use javascript/jQuery for showing the cirle.



              If this didn't help - then please provide the code you use to generate the number.






              share|improve this answer












              Sounds like some loading issues. Try moving your css from being loaded in the top of the HTML, to be loaded in the bottom/footer.



              What you want to do, is to hide the circle until the result is loaded (either 0 or 1,2,3,4.. and so on. Depending on the number of notifications).



              In your div you got this line style="display:none"> which hides the circle. Thats good!



              Now you should make sure that the style for .unseen-notification-show which contains display: block !important; that shows the circle - Should not be run before the calculation of the number to show is done.



              One way could be to place the file that loads your css to the bottom of the HTML (like moving your <link rel="stylesheet" href="test.css" />). Or another way is to only use css for the hiding and then use javascript/jQuery for showing the cirle.



              If this didn't help - then please provide the code you use to generate the number.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 20 '18 at 12:28









              JonasB

              194111




              194111












              • I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
                – George Krialashvili
                Nov 20 '18 at 14:10










              • What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
                – JonasB
                Nov 20 '18 at 14:26












              • if I remove visible it will just stay displayed
                – George Krialashvili
                Nov 20 '18 at 14:58










              • Ok. I don’t have a solution then :(
                – JonasB
                Nov 20 '18 at 17:55


















              • I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
                – George Krialashvili
                Nov 20 '18 at 14:10










              • What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
                – JonasB
                Nov 20 '18 at 14:26












              • if I remove visible it will just stay displayed
                – George Krialashvili
                Nov 20 '18 at 14:58










              • Ok. I don’t have a solution then :(
                – JonasB
                Nov 20 '18 at 17:55
















              I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
              – George Krialashvili
              Nov 20 '18 at 14:10




              I tried to make the div first display none and then to make it visible with data-bind css but the problem is for the circle that works but for then I have the number with data-bind text and number shows 0 shows up like it does with empty circle and without style and disappears and then shows normali. so I think problem is that data binds data binds and style load faster than the code that finds unseen notification numbers
              – George Krialashvili
              Nov 20 '18 at 14:10












              What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
              – JonasB
              Nov 20 '18 at 14:26






              What happens if you remove the visible: UnSeenMessagesCount() > 0, from the data-bind and move your css to the footer?
              – JonasB
              Nov 20 '18 at 14:26














              if I remove visible it will just stay displayed
              – George Krialashvili
              Nov 20 '18 at 14:58




              if I remove visible it will just stay displayed
              – George Krialashvili
              Nov 20 '18 at 14:58












              Ok. I don’t have a solution then :(
              – JonasB
              Nov 20 '18 at 17:55




              Ok. I don’t have a solution then :(
              – JonasB
              Nov 20 '18 at 17:55











              0














              I think the issue is due to
              self.UnSeenMessagesCount = ko.observable(0);
              so when your modal is getting created it is initialized with value 0. So when you refresh the page initially it is 0 but when self.getMessage is called it updates your value.






              share|improve this answer


























                0














                I think the issue is due to
                self.UnSeenMessagesCount = ko.observable(0);
                so when your modal is getting created it is initialized with value 0. So when you refresh the page initially it is 0 but when self.getMessage is called it updates your value.






                share|improve this answer
























                  0












                  0








                  0






                  I think the issue is due to
                  self.UnSeenMessagesCount = ko.observable(0);
                  so when your modal is getting created it is initialized with value 0. So when you refresh the page initially it is 0 but when self.getMessage is called it updates your value.






                  share|improve this answer












                  I think the issue is due to
                  self.UnSeenMessagesCount = ko.observable(0);
                  so when your modal is getting created it is initialized with value 0. So when you refresh the page initially it is 0 but when self.getMessage is called it updates your value.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 20 '18 at 18:20









                  vinit_tiwari

                  112




                  112






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53389705%2fcss-style-shows-after-refresh-and-then-goes-invisible-with-knockout%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                      Alcedinidae

                      Can an atomic nucleus contain both particles and antiparticles? [duplicate]