Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

simple jQuery dialog

General discussions related to php

Moderators: macek, egami, gesf

simple jQuery dialog

Postby dxshindeo » Mon Aug 06, 2012 10:05 am

Hi, everyone!

So this is a working jQuery dialog, which is activated by pressing button with id #opener:

Code: Select all
<script type="text/javascript">
 $(document).ready(function() {
  var $dialog = $('<div></div>')
   .html('This dialog will show every time!')
   .dialog({
    autoOpen: false,
    title: 'Basic Dialog'
   });

  $('#opener').click(function() {
   $dialog.dialog('open');
   // prevent the default action, e.g., following a link
   return false;
  });
 });
 </script>
 
 <button id="opener">Open the dialog</button>



Now I want to open it with clicking an image, not button.
Basically what I did was substituted ".click" function with a new function itself:


Code: Select all
<script type="text/javascript">
 $(document).ready(function() {
  var $dialog = $('<div></div>')
   .html('This dialog will show every time!')
   .dialog({
    autoOpen: false,
    title: 'Basic Dialog'
   });


   function show_dialog(){
   $dialog.dialog('open');
   // prevent the default action, e.g., following a link
   return false;
  };
 });
 </script>


<img src="images/edit.jpg" class="edit_set" onClick="show_dialog()">


It should work, but, well, it doesn't xD
Can anyone point me in the right direction?
Last edited by dxshindeo on Mon Aug 06, 2012 10:07 am, edited 1 time in total.
dxshindeo
New php-forum User
New php-forum User
 
Posts: 8
Joined: Mon Jul 02, 2012 1:31 pm

Re: simple jQuery dialog

Postby dxshindeo » Mon Aug 06, 2012 10:06 am

I know this isn't purely php, but im going to implement mysql queries in this sooner or later. Just have to get this working first.
dxshindeo
New php-forum User
New php-forum User
 
Posts: 8
Joined: Mon Jul 02, 2012 1:31 pm

Re: simple jQuery dialog

Postby TomCornar » Sun Sep 16, 2012 11:16 pm

try with below code,
<input type="image" src="" id="opener">

Regards,
Tom Cornar
Trinay Technology Solutions
http://www.trinay.com
User avatar
TomCornar
New php-forum User
New php-forum User
 
Posts: 25
Joined: Fri Sep 14, 2012 12:06 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron