Element: blur event (onblur)

Description

The blur event fires when an element has lost focus .

The main difference between this event and focusout is that focusout bubbles while blur does not.

Interface: FocusEvent

Event handler property: onblur

Examples

 1 {% for form_codif_nomenclature in formset_codif_nomenclature %}
 2     var designation_mde_{{ forloop.counter0 }} = new SimpleMDE(
 3         {
 4             element: document.getElementById('id_codifnomenclature_related-{{ forloop.counter0 }}-designation'),
 5             toolbar: false,
 6             status: false,
 7             spellChecker: false,
 8         });
 9
10     {# Par défaut le mode preview est activé #}
11     designation_mde_{{ forloop.counter0 }}.togglePreview();
12
13     designation_mde_{{ forloop.counter0 }}.codemirror.on("blur", function(){
14         let designation = designation_mde_{{ forloop.counter0 }}.value();
15         console.log("designation", designation );
16         let codifnomenclature_id = $('#id_codifnomenclature_related-{{ forloop.counter0 }}-id').val();
17         let url = '{% url "articles:ajax_update_codif_nomenclature" %}';
18         $.ajax(
19                 {
20                     url: url,
21                     data: {
22                         'id': codifnomenclature_id,
23                         'designation': designation,
24                     },
25                     dataType: 'json',
26                     success: function (data) {
27                     }
28             }
29         );
30     });
31    document.getElementById("id_description_toggle_preview_{{ forloop.counter0 }}").onclick = function()
32    {
33        designation_mde_{{ forloop.counter0 }}.togglePreview();
34    };
35
36 {% endfor %}