How to remove summernote style

Asked

Viewed 84 times

0

Hello, I’m using summernote and putting a width on a div only when I save my style just disappear and it puts another one in place. I will send photo and also my html code.

<div class="div-btn" style="width:100%!important;"></div>

This above is my code but it turns into this when I save:

<div class="div-btn" style="width: 483px; color: rgb(54, 54, 54); font-size: 16.6px; text-align: center !important;"></div>

I’ve done everything, I even used javascript but I don’t know why it doesn’t work. I’ll send you my javascript too.

$(document).ready(function() {

$('#salvar').click(function() {
  var texto = $('#msg_consulta_marcacao').code();
  var div = $('div-btn');
  div.find('*').removeAttr('style');
  div.find('*').removeAttr("style").attr("style","width");

  textoConteudo = $(texto.replace(/&nbsp;|<br>/g, ' ')).text().trim();
  if(textoConteudo.length <= 0) {
    $('#msg_consulta_marcacao').html("");
  }
  else{
    $('#msg_consulta_marcacao').html($('#msg_consulta_marcacao').code());
  }
  
  this.disabled=true;
  this.form.submit();

}
);

  $('#padrao').summernote({
    height: 430,
    toolbar: [
            ]
  });

  $("#msg_consulta_marcacao").summernote({
  height: 400,
  toolbar: [
                ["style", ["style"]],
                ["font", ["bold", "underline", "clear"]],
                ["fontname", ["fontname"]],
                ["color", ["color"]],
                ["para", ["ul", "ol", "paragraph"]],
                ["table", ["table"]],
                ["insert", ["link", "picture"]],
                ["view", ["codeview"]]
            ],
  hint: {
    words: ['primeironome_pcte', 'nome_pcte', 'nome_profissional', 'data_agendamento', 'hora_agendamento', 'procedimento_agendamento', 'local_agendamento', 'endereco_agendamento'],
    match: /\b(\w{1,})$/,
    search: function (keyword, callback) {
      callback($.grep(this.words, function (item) {
        return item.indexOf(keyword) === 0;
      }));
    }
  }
});

  });

Thank you!

  • It seems that you are trying to take width by JS, but actually try to put a min-width:100% in it. In css the min-width override the width, it might work. And it seems to me that this selector is wrong! var div = $('div-btn'); sap var div = $('.div-btn'); with a . in the class name

  • I corrected and did what you said but it still didn’t work :(

  • Maybe the js plugin for summernote is adding this value and overwriting its "width". Try adding this value to your div-btn class. Ex: ". div-btn {width:100%! Important;}" in your css.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.