Blueimp - disable delete button for previously uploaded images

When I upload files via the blueimp upload script, the file information is saved in the datasheet along with the upload timestamp. Now when I edit the form the files appear again.

I want to do a simple thing ... if the current timestamp is less than the file's timestamp (previously loaded) the delete button will be disabled.

For this reason, I need to use Ajax to validate it. But <script type='text/x-tmpl'></script>

nothing works in tags .

I don't know what x-tmpl is. I searched the web and found that this is some kind of pattern. Can javascript be used with these x-tmpls?


I want to do something like the following:

<script id="template-download" type="text/x-tmpl">
    {% if (file.deleteUrl) { %}
    </script>
    <script type="text/javascript">
        var checkAvailability = $.ajax({
            type: 'GET',
            url: "request.php?file="+{% file.deleteUrl %},
            dataType: 'html',
            context: document.body,
            global: false,
            async:false,
            success: function(data) {
            return data;
            }
        }).responseText;
        if(!checkAvailability){
            <button class="btn btn-danger btn-xs delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %} DISABLED>
                <i class="glyphicon glyphicon-trash"></i>
                <span>Delete</span>
            </button>
        } else{
            <button class="btn btn-danger btn-xs delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
                <i class="glyphicon glyphicon-trash"></i>
                <span>Delete</span>
            </button>
        }
    </script>
    <script id="template-download" type="text/x-tmpl">
    {% }

      

Any help or suggestions how can I use AJAX on this tag x-tmpl

for the purpose of validating the timestamp?

+3


source to share





All Articles