jquery custom box (onload ipv onclick)
Hallo,
Ik heb dit script van internet gedownload:
SCRIPT.JS
JQUERY.CONFIRM.JS
Die roep ik op met
<div class="item"><div class="delete"></div></div>
Dan komt er een kruisje waar ik op moet klikken en dan verschijnt er een menu van wil je naar de beta ja of nee.
Maar ik wil dat als je de site laad dat er dan dat scherm komt.dus met onload en niet hoe het nu is onclick
Ik heb dit script van internet gedownload:
SCRIPT.JS
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$(document).ready(function(){
$('.item .delete').click(function(){
var elem = $(this).closest('.item');
$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){
elem.slideUp();
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
},
}
});
});
});
$('.item .delete').click(function(){
var elem = $(this).closest('.item');
$.confirm({
'title' : 'Delete Confirmation',
'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?',
'buttons' : {
'Yes' : {
'class' : 'blue',
'action': function(){
elem.slideUp();
}
},
'No' : {
'class' : 'gray',
'action': function(){} // Nothing to do in this case. You can as well omit the action property.
},
}
});
});
});
JQUERY.CONFIRM.JS
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
(function($){
$.confirm = function(params){
if($('#confirmOverlay').length){
// A confirm is already shown on the page:
return false;
}
var buttonHTML = '';
$.each(params.buttons,function(name,obj){
// Generating the markup for the buttons:
buttonHTML += '<a href="#" class="button '+obj['class']+'">'+name+'<span></span></a>';
if(!obj.action){
obj.action = function(){};
}
});
var markup = [
'<div id="confirmOverlay">',
'<div id="confirmBox">',
'<h1>',params.title,'</h1>',
'<p>',params.message,'</p>',
'<div id="confirmButtons">',
buttonHTML,
'</div></div></div>'
].join('');
$(markup).hide().appendTo('body').fadeIn();
var buttons = $('#confirmBox .button'),
i = 0;
$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){
// Calling the action attribute when a
// click occurs, and hiding the confirm.
obj.action();
$.confirm.hide();
return false;
});
});
}
$.confirm.hide = function(){
$('#confirmOverlay').fadeOut(function(){
$(this).remove();
});
}
})(jQuery);
$.confirm = function(params){
if($('#confirmOverlay').length){
// A confirm is already shown on the page:
return false;
}
var buttonHTML = '';
$.each(params.buttons,function(name,obj){
// Generating the markup for the buttons:
buttonHTML += '<a href="#" class="button '+obj['class']+'">'+name+'<span></span></a>';
if(!obj.action){
obj.action = function(){};
}
});
var markup = [
'<div id="confirmOverlay">',
'<div id="confirmBox">',
'<h1>',params.title,'</h1>',
'<p>',params.message,'</p>',
'<div id="confirmButtons">',
buttonHTML,
'</div></div></div>'
].join('');
$(markup).hide().appendTo('body').fadeIn();
var buttons = $('#confirmBox .button'),
i = 0;
$.each(params.buttons,function(name,obj){
buttons.eq(i++).click(function(){
// Calling the action attribute when a
// click occurs, and hiding the confirm.
obj.action();
$.confirm.hide();
return false;
});
});
}
$.confirm.hide = function(){
$('#confirmOverlay').fadeOut(function(){
$(this).remove();
});
}
})(jQuery);
Die roep ik op met
<div class="item"><div class="delete"></div></div>
Dan komt er een kruisje waar ik op moet klikken en dan verschijnt er een menu van wil je naar de beta ja of nee.
Maar ik wil dat als je de site laad dat er dan dat scherm komt.dus met onload en niet hoe het nu is onclick
Gewijzigd op 03/03/2011 17:02:39 door Jordi Kroon
Dan haal je regel 3 en regel 25 van je script.js weg.
Want wat dat allemaal betekend:
$(document).ready(function(){
Als het document klaar is om te beginnen (onLoad). Voer dan een functie uit.
$('.item .delete').click(function(){
Als je op een element met de class item of delete klikt (onClick). Maak dan een functie.
Weggelaten plugin info
});
Sluit de click functie
});
Sluit de onLoad functie.
Want wat dat allemaal betekend:
$(document).ready(function(){
Als het document klaar is om te beginnen (onLoad). Voer dan een functie uit.
$('.item .delete').click(function(){
Als je op een element met de class item of delete klikt (onClick). Maak dan een functie.
Weggelaten plugin info
});
Sluit de click functie
});
Sluit de onLoad functie.
ow dat was simpel xD ik ben niet zo van jquery maar bij sommige dingen is het toch wel handig . Ik dacht dat ik iets met die $(document).ready(function(){ moest doen




