longlostnick / bootstrap-growl

Pretty simple jQuery plugin that turns standard Bootstrap alerts into "Growl-like" notifications.
http://ifightcrime.github.io/bootstrap-growl
MIT License
806 stars 207 forks source link

Do not create inline HTML, instead use the relevant jQuery functions #62

Open softwarespot opened 9 years ago

softwarespot commented 9 years ago

It's best to do something like this when creating a new HTML element...

// Close button
var $button = $('<button/>')
        .attr('type', 'button')
        .addClass('close')
        .attr('data-dismiss', 'alert')
        .attr('aria-label', 'Close'),

    // The small 'x'
    $cross = $('<span/>')
        .attr('aria-hidden', 'true')
        .html('&times;');

// Append the cross to the button element
$button.append($cross);

// Append the close button to the alert and add the class
// that it's dimissible
$alert.append($button)
    .addClass('alert-dismissible');

You can see that I have done this in my fork