Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble creating Popover initialised via Javascript or Data API #277

Closed
timwaters opened this issue Apr 5, 2019 · 6 comments
Closed

Trouble creating Popover initialised via Javascript or Data API #277

timwaters opened this issue Apr 5, 2019 · 6 comments
Labels
enhancement potential improvement

Comments

@timwaters
Copy link

I'm having trouble creating and showing a Popover created via Javascript
I'm able to initialise the Popover but not able to access the public methods.

<div id="popup"></div>

var element = document.getElementById('popup');

var pop = new Popover(element, {
  title: 'title',
  placement: 'top',
  content: 'the content',
  animation: 'slideNfade', 
  delay: 100, 
  dismissible: true
});

//element.Popover.show(); //element.Popover is undefined
pop.show();  //pop.show is not a function

I also tried using the data API using the example from the docs, with no luck.

Here's a codepen showing my progress:

https://codepen.io/anon/pen/VNagOG

@thednp
Copy link
Owner

thednp commented Apr 5, 2019

var element = document.getElementById('my-button');

@thednp thednp closed this as completed Apr 5, 2019
@thednp thednp added the invalid not related or critical label Apr 5, 2019
@timwaters
Copy link
Author

timwaters commented Apr 5, 2019

Thanks @thednp

Should anyone else be having trouble in the future, I think that the element must have at least the data-content Data API attribute added to it for this to work, as programmatically adding a Popover to an element without one doesn't appear to be working with the same code.

<div id="popup" data-content="Popover in middle"></div>

https://codepen.io/anon/pen/eoZamY shows it working.

However the 'content' option does not override the data-content of the element.

@thednp thednp added enhancement potential improvement and removed invalid not related or critical labels Apr 5, 2019
@thednp
Copy link
Owner

thednp commented Apr 5, 2019

I'm gonna rework components init so that JS initialization has priority over data-optionNAME values.

@thednp thednp reopened this Apr 6, 2019
@thednp
Copy link
Owner

thednp commented Apr 9, 2019

The Popover component indeed didn't take any reading of options.title and options.content; I also found some inconsistencies with ScrollSpy, but they all gonna get fixed with the next commit, so stay tuned.

@timwaters
Copy link
Author

good stuff and thanks for a good library!

thednp added a commit that referenced this issue Apr 9, 2019
* moved build scripts to `/lib` folder
* created an unified & updated build script for both V3/V4, check updated WIKI pages for user guide updates
* fixed Popover not working with `options.title` and `options.content`, the script didn't read any of that #277
* fixed ScrollSpy to use `options.target` first before going after `data-target` (found after investigating #277)
* NEW: added TOUCH events for Carousel, the component will now use `slideTo` method after a 75px long swipe left/right #275
* improved the Collapse component to work better with JavaScript init #276
thednp added a commit that referenced this issue Apr 9, 2019
* moved build scripts to `/lib` folder
* created an unified & updated build script for both V3/V4, check updated WIKI pages for user guide updates
* fixed Popover not working with `options.title` and `options.content`, the script didn't read any of that #277
* fixed ScrollSpy to use `options.target` first before going after `data-target` (found after investigating #277)
* NEW: added TOUCH events for Carousel, the component will now use `slideTo` method after a 75px long swipe left/right #275
* improved the Collapse component to work better with JavaScript init #276
@thednp
Copy link
Owner

thednp commented Apr 9, 2019

@timwaters
Please download latest master and give it a try, let me now how it goes.

@thednp thednp closed this as completed Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement potential improvement
Projects
None yet
Development

No branches or pull requests

2 participants