Git Product home page Git Product logo

Comments (5)

MihaiSlujitoru avatar MihaiSlujitoru commented on July 22, 2024

I'm looking for similar functionality. Did you figure it out?

from modaal.

hoangemini avatar hoangemini commented on July 22, 2024

I'm looking for similar functionality. Did you figure it out?

I tried to fix the source but it failed! I had to trigger the submit button to open the modal, which was silly

from modaal.

pzi avatar pzi commented on July 22, 2024

Have you tried

$('.inline').modaal({
	content_source: '#inline'
	start_open: true
});

as per the docs?

See: https://github.com/humaan/Modaal#32-programatically-open-a-modaal

from modaal.

MihaiSlujitoru avatar MihaiSlujitoru commented on July 22, 2024

@pzi Yes, but I want to open the modal based on actions not when the website first loads. Something like they complete a form and then show up the modal if the form submits, as an example.

from modaal.

pzi avatar pzi commented on July 22, 2024

CodePen example of triggering the form on form submit:
https://codepen.io/pzi/pen/MWKXgxg

HTML

<form>
  <label>
    Foo
    <input />
  </label>
  <button>Submit</button>
</form>

<div id="inline-content" class="trigger">...</div>

CSS

#inline-content {
  display: none;
}

JS

// init modaal
$(".trigger").modaal({ content_source: "#inline-content" });

$("form").on("submit", (event) => {
  event.preventDefault();
  // open modaal on submit
  $(".trigger").modaal("open");
});

Disclaimer: haven't used Modaal that much, so unsure if the "trigger" being on the same as the modaal content is legit, but it seems to work. Can always chuck the trigger class on another element if it's an issue.

from modaal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.