Damon
Damon

Reputation: 10809

Can't disable bootstrap modal windows

Using twitter bootstrap I want to conditionally disable the modal windows that it calls. I have this function:

Link like:

<a data-toggle="modal" href="#contact">Contact</a>

JS like:

if (Modernizr.touch){
$("a[data-toggle='modal']").each(function() {
    this.href = this.href.replace('/#', '/');
    $(this).data('toggle', '');
});
}

I have this script included before bootstrap.min.js is loaded, but still when I click on the links now nothing happens. I think that it's related to the data-toggle attribute, but I have no idea how else to get rid of it.

Thinking of switching it and trying to add the attribute, but I doubt that will work (for the same reason) and I'd prefer not to have to change the markup.

Upvotes: 2

Views: 7700

Answers (1)

Sara
Sara

Reputation: 8242

You could try:

$(this).removeAttr("data-toggle");

Upvotes: 6

Related Questions