Please Log-in or Register to get full access to the forums.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Trigger a modal popup via a javascript function, not an element
24th April, 14:14
Post: #1
[Solved] Trigger a modal popup via a javascript function, not an element
Hi,

For the project I am working on, I require to launch a modal popup without an event associated to it. Basically, according to an event that happens in the backend, a javascript function would be executed to show a specific popup.

The problem I have is that I do not want an element nor an event associated to it since it is not executed via a button or an html element, it's just a js function which is executed.

This code should give you an idea of what im after, I have a couple of comments in there as well

LANGUAGE Code
function showmodal(modalid){
		qtip({ // notice the qtip function does not have a selector because there isn't one. Is this possible?
			content: {text: $('div#' + modalid)},
			position: {
				my: 'center',
				at: 'center',
				target: $(window)
			},
			show: {
                                // there is no event bound to it, since it not executed according to a user input
				solo: false,
				modal: {
					on: true,
					blur: false,
					escape: false
				}
			},
			hide: false,
			style: 'ui-tooltip-light ui-tooltip-rounded modal-popup-inner'
		});
	}


Using the above code, what I need is that by executing a command from javascript such as showmodal('mydivid'), the modal would be triggered showing the contents of 'mydivid' within it. Is this doable?

Thanks a lot in advance.
Find all posts by this user
Quote this message in a reply
24th April, 15:54
Post: #2
RE: Trigger a modal popup via a javascript function, not an element
Use a dummy div Smile
JS Code
var modal = $('<div/>').qtip().qtip('api');
 
modal.show(); // Show it
modal.hide(); // Hide it
Visit this user's website Find all posts by this user
Quote this message in a reply
24th April, 18:58 (This post was last modified: 24th April 19:24 by ganniv.)
Post: #3
RE: Trigger a modal popup via a javascript function, not an element
(24th April 15:54)Craig Wrote:  Use a dummy div Smile
JS Code
var modal = $('<div/>').qtip().qtip('api');
 
modal.show(); // Show it
modal.hide(); // Hide it

Sorry to bug you again, but I dont know exactly what Im supposed to do with this Sad

I tried applying it but nothing happens. I just get a js error that modal is undefined. When i change the '<div/>' to an actual element it still gives an error that it's null.

I created a jsFiddle example (although it doesnt work). Please ignore that it is triggered via an onClick event, I did this purely for the test's purposes. In practice I wont execute the JS function from the HTML itself:
http://jsfiddle.net/fDavN/3188/
Find all posts by this user
Quote this message in a reply
24th April, 19:59
Post: #4
RE: [Solved] Trigger a modal popup via a javascript function, not an element
See here Smile http://jsfiddle.net/fDavN/3189/
Visit this user's website Find all posts by this user
Quote this message in a reply
24th April, 20:17
Post: #5
RE: [Solved] Trigger a modal popup via a javascript function, not an element
(24th April 19:59)Craig Wrote:  See here Smile http://jsfiddle.net/fDavN/3189/

Brilliant dude. Cannot thank you enough for your full support. Will make sure to do a nice donation once the project is over. This library saved us an exceptionally huge amount of time.

Thanks again! Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Settings position target to parent element dev4press 0 103 20th October 17:37
Last Post: dev4press
  Qtip configure to have two trigger events, one on page load and one on hover spwood23 0 180 9th August 15:18
Last Post: spwood23
  [Solved] Ajax, Modal, and Centering in Window AdamCapriola 5 1,166 12th June 14:15
Last Post: AdamCapriola
  [Solved] Can you genreate the qTip HTML inside the parent element? WebbedIT_PG 5 2,834 11th June 14:08
Last Post: KelownaGuy
  [Bug] Target element disappears when using 'title' frexuz 3 509 25th April 13:14
Last Post: frexuz
  [Solved] Two tooltips on the same element yuco91 4 916 22nd April 16:23
Last Post: ChicagoOutfit
  Need help with javascript implementation bumpusdoggie 3 401 15th April 15:40
Last Post: bumpusdoggie
  [Solved] qTip in Bootstrap modal dialog sbwmikael 2 861 5th March 01:34
Last Post: sbwmikael
  [Solved] remotely trigger a qTip popup porterfoster 5 611 28th January 17:54
Last Post: porterfoster
  [Solved] Hide modal until ajax is loaded? phpmysqlguy 4 672 12th January 16:36
Last Post: Craig



User(s) browsing this thread: 1 Guest(s)