humaan / Modaal

An accessible dialog window library for all humans.

Home Page:http://humaan.com/modaal/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expression item.href !== '' || item.href !== undefined always return true

ildarnm opened this issue · comments

commented

I use an image tag and for this tag the expression item.href !== '' || item.href !== undefined always returns true.

if ( item.href !== '' || item.href !== undefined ) {

@ildarnm I assume you're having some sort of issue with this, can you please provide some more information:

  • Please describe your expected result versus the actual result. You can using jsFiddle or jsBin if you can't provide any other example of your issue.
  • Please also share your implementation (html and js) here so we can try to help you.

I think I may have had a similar issue.
I followed the example to create an image gallery but every time I clicked an image the model was empty - the img tag src was set as undefined.

If you look at line 614 of modaal.js it tests for the presence of data in the href attribute as per the demo example

<a href="path/to/image-1.jpg" data-group="gallery" class="gallery">Show</a>

but it then assigns the value of data-modaal-content-source to the modal image.

Having followed the example I didn't have this data attribute so the image src was never populated properly.

I solved the problem without editing modaal.js by adding the data-modaal-content-source data attribute to the link eg

<a href="/_images/gallery1.jpg" data-group="gallery" class="gallery" data-modaal-content-source="/_images/gallery1.jpg">

Always looking for the simplest solution, I'd suggest changing the demo code to

<a href="path/to/image-1.jpg" data-group="gallery" class="gallery" data-modaal-content-source="path/to/image-1.jpg">Show</a>

I'd love to make a contribution so do let me know if you'd like me to have a go at changing the code to use the href instead.

thanks @TimSmith714 and @ildarnm for raising this issue, upon closer inspection we have identified a bug as a result of some semi-recent enhancements that were rolled out.

A new release has just been made available out which addresses and resolves this issue. https://github.com/humaan/Modaal/releases/tag/v0.4.3