Draw characters in id

Asked

Viewed 39 times

0

I have a code that when I click the button to deactivate photo it makes disappear the button that is next. To get this function to work, I had to pass in id a few characters before, it was like this:

<a href="javascript:void(0);" id="semEmi<?= $l->img_id ?>"></a>

in id that part that is written (semEmi) I put for the button to do its function. However, when I click on this button, before deactivating the photo, it picks up these characters (semEmi), it does not work. I don’t know how to remove these characters when clicking this button. My code is in MVC

Here is the Javascript that makes the functions by clicking on it:

$(document).on('click', '.semEmi', function () {
    var t = $(this);
    $.SmartMessageBox({
        title: "<?= $this->lang->line("
        con_inflaud_jus_msg_title "); ?>",
        content: "<?= $this->lang->line("
        con_inflaud_jus_msg_d "); ?>",
        buttons: "[<?= $this->lang->line("
        con_inflaud_jus_msg_btn_n "); ?>][<?= $this->lang->line("
        con_inflaud_jus_msg_btn_y "); ?>]",
        input: "text",
        inputValue: "",
        placeholder: "<?= $this->lang->line("
        con_inflaud_jus_msg_place "); ?>"
    }, function (ButtonPress, Value) {
        if (ButtonPress == "<?= $this->lang->line("
        con_inflaud_jus_msg_btn_n "); ?>") {
            return 0;
        } else {
            if (Value == "") {
                notifica('<?= $this->lang->line("con_inflaud_msg_erro_title"); ?>', '<?= $this->lang->line("con_inflaud_jus_msg_inpmpt"); ?>', 4000);
            } else {
                $.ajax({
                    type: "POST",
                    url: "Controller/Funcao/" + $(t).attr('id') + "/2",
                    data: {
                        justificativa: Value
                    },
                    dataType: "json",
                    success: function (r) {
                        if (r) {
                            $(t).parent().parent().next().find('.graf_lau').show();
                            $(t).parent().parent().next().find('.blockquote').show();
                            $(t).parent().parent().next().find('.img_lau_d').show();
                            $(t).parent().parent().next().find('.img_lau_a').css('display', 'none');
                            $(t).removeClass('semEmi btn-default');
                            $(t).addClass('comEmi btn-warning');
                            $(t).empty();
                            $(t).append('<span class="btn-label"><i class="fa fa-check-square-o"></i></span><?= $this->lang->line("con_inflaud_afe_comEmi"); ?>');
                        } else {
                            notifica('<?= $this->lang->line("con_inflaud_msg_erro_title"); ?>', '<?= $this->lang->line("con_inflaud_msg_erro_d"); ?>', 4000);
                        }
                    }
                });
            }
        }
    });
});
  • You want us to "Controller/Funcao/" + $(t).attr('id') + "/2" the id contains only the numbers, without the string semEmi, that’s it ?

  • That’s right @Dontvotemedown

  • 1

    Use $(t).attr('id').replace("semEmi", "")

No answers

Browser other questions tagged

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