Az miért van, hogy php-ben, foreach-el kirakok 2 elemet, mind a kettőn ugyanaz a button van, ugyanazzal az id-val és az elsőnél feljön az ablak, a másodiknál viszont nem reagál semmire a button.
Itt van a kód : [link] , A download gombra kattintva leszedi ugyanezt egy szimpla html-ben, ott elég jól lehet látni mindent. itt a confirmot használom, nálam így néz ki a kód;
$(document).ready(function()
{
/*
* Common dialogue() function that creates our dialogue qTip.
* We'll use this method to create both our prompt and confirm dialogues
* as they share very similar styles, but with varying content and titles.
*/
function dialogue(content, title) {
/*
* Since the dialogue isn't really a tooltip as such, we'll use a dummy
* out-of-DOM element as our target instead of an actual element like document.body
*/
$('<div />').qtip(
{
content: {
text: content,
title: title
},
position: {
my: 'center', at: 'center', // Center it...
target: $(window) // ... in the window
},
show: {
ready: true, // Show it straight away
modal: {
on: true, // Make it modal (darken the rest of the page)...
blur: false // ... but don't close the tooltip when clicked
}
},
hide: false, // We'll hide it maunally so disable hide events
style: 'ui-tooltip-light ui-tooltip-rounded ui-tooltip-dialogue', // Add a few styles
events: {
// Hide the tooltip when any buttons in the dialogue are clicked
render: function(event, api) {
$('button', api.elements.content).click(api.hide);
},
// Destroy the tooltip once it's hidden as we no longer need it!
hide: function(event, api) { api.destroy(); }
}
});
}
// Our Confirm method
function Confirm(question, callback)
{
// Content will consist of the question and ok/cancel buttons
var message = $('<p />', { text: question }),
ok = $('<button />', {
text: 'Ok',
click: function() { callback(true); }
}),
cancel = $('<button />', {
text: 'Cancel',
click: function() { callback(false); }
});
dialogue( message.add(ok).add(cancel), 'Photofreak' );
}
// Setup the buttons to call our new Alert/Prompt/Confirm methods
$('#confirm').click(function() {
Confirm('Are you sure you want to delete this photograph?', function(yes) {
// do something with yes
});
});
});
A fölösleges részeket kiszedtem. A button így néz ki :
<button class="button" id="confirm" type="button" >Delete</button>
Köszönöm előre is.
Szerk : Jah és még egy kérdés, hogy tudom elérni, hogy a yes-re kattintva a formot elinditsa? Magyarul ugyanazt megcsinálja mintha egy szimpla submit lenne egy html form alján.
[ Szerkesztve ]