Changeset 617 for trunk/js


Ignore:
Timestamp:
Nov 11, 2017 1:13:38 PM (6 years ago)
Author:
anonymous
Message:

Add console warning if target element not found.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/js/Msg.js

    r552 r617  
    4747Strangecode.Msg = function (options) {
    4848    // Merge options with defaults
    49     this.o = $.extend({
     49    var options = this.o = $.extend({
    5050        container: '.sc-msg:last',
    5151        above_msg: '',
    5252        gotohash: true
    5353    }, options || {});
     54
     55    document.addEventListener('DOMContentLoaded', function (e) {
     56        // Warn if the target doesn't exist.
     57        if (!$(options.container).length) {
     58            console.warn('Strangecode.Msg container not found: ' + this.o.container);
     59        }
     60    });
    5461};
    5562
     
    7077    }
    7178    // Use 'sc-msg-error' as default class string.
    72     msg_class = (typeof msg_class === 'undefined') ? 'sc-msg-error' : msg_class;
     79    var msg_class = (typeof msg_class === 'undefined') ? 'sc-msg-error' : msg_class;
    7380    // Append this raised message to the sc-msg stack, if it doesn't exist already.
    7481    if (!$(this.o.container).find(':contains("' + message + '")').length) {
Note: See TracChangeset for help on using the changeset viewer.