Skip to content

Commit

Permalink
Adds refresh method to re-fetch [data-modal]
Browse files Browse the repository at this point in the history
See scottaohara#6 for more information.

I know this isn't the best solution, but I'm not a great JS developer.

Another alternative would be to add something like this:

```
/**
	 * @param {Element} item
	 */
	ARIAmodal.addModal = function ( item ) {
		modal.push( item );	
	};
```

and then refactor `setupModal` so it runs only on one modal at a time, then add a new `setupModals` method that would loop through all the items in the `modal` array and run `setupModal` on them.

Again, I'm not great at JS. Thank you for the script, and please let me know if I can help with the PR.
  • Loading branch information
zackkatz authored Jul 18, 2018
1 parent dca3f38 commit 1481d8e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,17 @@
}
};


/**
* If modals are being added to the DOM dynamically, redefine the modal variable
* and initialize again.
*/
ARIAmodal.refresh = function () {
modal = doc.querySelectorAll('[data-modal]');
ARIAmodal.init();
};


/**
* Initialize modal functions.
* If expanding this script, put
Expand Down

0 comments on commit 1481d8e

Please sign in to comment.