2011-08-13 5 views
0

私はそれはjavascriptの確認メッセージのこのような使用している を(簡単な機械フォーラム)フォーラムのスクリプトで働いています:jgrowlを使用してダイアログのように確認を確認するにはどうすればよいですか?

<a href="http://domain.net/index.php?action=deletemsg;topic=1.0;msg=1;c6c7a67=f9e1fd867513be56e5aaaf710d5f29f7" onclick="return confirm('Remove this message?');">Remove</a> 

を私が代わりにすることをjgrowlを使用したい...何かのように:

<a href="http://domain.net/index.php?action=deletemsg;topic=1.0;msg=1;c6c7a67=f9e1fd867513be56e5aaaf710d5f29f7" onclick="$.jGrowl('Remove this message?', { header: 'Confirmation', sticky: true });"/>Remove</a> 

... jgrowlを使用してtrue/false JavaScriptのリターンを達成するにはどうすればよいですか? これは1行で完了できますか?

よろしくお願いいたします。 ルチアーノ

答えて

0

はjGrowlはモーダルと、ページの動作をブロックしませんので、あなたがちょうどそのようにそれを行うことができないのhref

を使用してサポートするように編集します。この例を使用すると、選択が行われた後に実行したいコードのための関数を作成し、次にチェック

通知の中からそれを呼び出すことができますしかし

http://jsfiddle.net/rcxVG/11/

html 

<body> 
    <a href="javascript: startDemo(1); alert('a');">link for 1</a><br> 
    <a href="javascript: startDemo(2); ">link for 2</a><br> 
     Will we notify again<div id="will-notitfy-again">yes</div> 

    <br> 
    now... If you want to return then 
    <a href="http://www.google.com" data-confirmed="false" onclick="return returnModal(this);">click me</a> 
</body> 

js

function startDemo(id) 
{ 
    $.jGrowl("to do not notify again click <a href='javascript:notFor("+id+")' onclick='closeNotif(this);'>here</a>!", { sticky: true }); 
} 

function notFor(id){ 
    alert("not anymore for "+id); 
    $("#will-notitfy-again").html("remember, notFor was hit for"+id); 

} 

function closeNotif(panel){ 
    $(".jGrowl-notification").has(panel).find(".jGrowl-close").click(); 
} 
var counter=0; 
var confirmedAttr="data-confirmed"; 
function returnModal(field){ 
    var $field=$(field); 
    if($field.attr(confirmedAttr)=="true"){ 
     location.href=$field.attr("href"); 
    }else{ 
     counter++; 
     //save the element somewhere so we can use it (don't know if it has an unique-id) 
     $(document).data("id"+counter,$field); 
     $.jGrowl("click <a href='javascript:confirmClick("+counter+")' onclick='closeNotif(this);'>here</a> to go to google!", { sticky: true }); 
     return false; 
    } 
} 
function confirmClick(variableId){ 
    var $field=$(document).data("id"+variableId); 
    $field.attr(confirmedAttr,"true"); 
    $field.click(); 
} 

これはenought

良かったなら、私を知ってみましょう
関連する問題