Click here to Skip to main content
15,885,546 members
Articles / Programming Languages / Javascript
Tip/Trick

Using a jQuery-UI Dialog in Meteor in Four Easy Steps

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
21 Sep 2015CPOL 11.2K   1   1
Easy-as-eating-gooseberry-pie handful of steps to incorporate a dialog into your Meteor app

jQuery-UI Eating Contest

Using a jQuery-UI modal dialog in your Meteor app is as easy as the proverbial pie (eating it, that is, not making it, which is decidedly more difficult); simply follow these steps:

  1. In the console, enter "meteor add linto:jquery-ui" to install the package.
  2. Add a "hide" CSS class:
    CSS
    .hide {
      visibility: hidden;
      display: none;
    }
  3. Add some HTML to the Template where the Dialog should display, hiding it by default, such as:
    HTML
    <template name="platypus"> <div id="duckbill" 
    name="duckbill"> <h2>Duckbilled Platypi of the World Unite!</h2> 
    <img alt="platypus image" height="275" id="imgPlatypusParty" 
    name="imgPlatypusParty" src="images/dplat.png" width="350" />
    </div> <div class="hide" id="dialog" title="Basic dialog"> 
    <p>Put whatever you want in here.</p> </div> </template>
  4. In response to some event, unhide the div and call dialog() on it, such as:
    JavaScript
    Template.platypus.events({
      'click #imgPostTravelBottom': function() {
        $( "#dialog" ).removeClass('hide');
        $( "#dialog" ).dialog(); }
    });

And that's all there is to it! It's almost as easy as falling off a log, and is as easy as pie, which is "funner."

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Across Time & Space
United States United States
I am in the process of morphing from a software developer into a portrayer of Mark Twain. My monologue (or one-man play, entitled "The Adventures of Mark Twain: As Told By Himself" and set in 1896) features Twain giving an overview of his life up till then. The performance includes the relating of interesting experiences and humorous anecdotes from Twain's boyhood and youth, his time as a riverboat pilot, his wild and woolly adventures in the Territory of Nevada and California, and experiences as a writer and world traveler, including recollections of meetings with many of the famous and powerful of the 19th century - royalty, business magnates, fellow authors, as well as intimate glimpses into his home life (his parents, siblings, wife, and children).

Peripatetic and picaresque, I have lived in eight states; specifically, besides my native California (where I was born and where I now again reside) in chronological order: New York, Montana, Alaska, Oklahoma, Wisconsin, Idaho, and Missouri.

I am also a writer of both fiction (for which I use a nom de plume, "Blackbird Crow Raven", as a nod to my Native American heritage - I am "½ Cowboy, ½ Indian") and nonfiction, including a two-volume social and cultural history of the U.S. which covers important events from 1620-2006: http://www.lulu.com/spotlight/blackbirdcraven

Comments and Discussions

 
SuggestionSome corrections Pin
Andreas Kroll22-Sep-15 2:29
Andreas Kroll22-Sep-15 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.