質問

私はコンテンツとしてリンクのhrefでモーダルウィンドウを作成するために、のjQuery Fancyboxプラグインを使用していますそのキャプションとして、そしてtitle。私はキャプションにクリック可能なリンクを持ってできるようにしたいと思います(この場合には、より大きなマップにつながること)が、私は<a>属性にtitleタグを置くことはできません。どのように私はJavascriptを、jQueryの、または他の方法を介してこのリンクを置くことについて行くかもしれない?

<a class='iframe' href='http://maps.google.com/maps?q=%235+Health+Department+Drive,+Troy,+MO+63379&amp;ll=38.979228,-90.97847&amp;z=13&amp;iwloc=near&amp;num=1&amp;output=embed' title='Google Map to Lincoln County Health Department'>Map to LCHD</a>

のように見えるもの

役に立ちましたか?

解決

私はこのプラグインに慣れていないんだけど、この方法は、頭に浮かぶ。

あなたはアンカー内のコンテンツ要素を埋めると、あなたの紹介の要素を使用するようにプラグイン変更することができます。たとえばます:

<a class='iframe' 
   href='http://maps.google.com/blahlblahlbah' 
   title='Google Map to Lincoln County Health Department'>Map to LCHD
   <span class="title-href" style="display: none">http://zebrakick.com</span>
</a>

希望に役立ちます。

他のヒント

そうでないかもしれない最高の提案が、あなたはあなた自身の属性を作ることができるかもしれない。このような何か。

<a class='iframe' href='http://maps.google.com/maps?q=%235+Health+Department+Drive,+Troy,+MO+63379&amp;ll=38.979228,-90.97847&amp;z=13&amp;iwloc=near&amp;num=1&amp;output=embed' title='Google Map to Lincoln County Health Department' dest="/path/to/file.ext">Map to LCHD</a>

オブジェクトとして要素=> destination_linkマップを保持し、リダイレクションのためにそれから値を取得します。

var linkmap = {
   lincoln:   '/location/3/',
   someplace: '/location/99'
}

今、あなたはあなたのクリックイベントにリンクマップからの値を使用することができます([]でか。演算子)

私は一緒に追加のデータを渡されます:

<a href="images/product.jpg" title="Product nummer 1" data-title-url="http://google.nl" rel="fancybox">

とタイトルを設定するためのカスタムコールバックを使用します:

{
    //fancybox options array
    titleFormat: function(title, currentArray, currentIndex, currentOpts){
        var currentElement = currentArray[currentIndex];

        var html = "<h1>" + title + "</h1>";
        var titleUrl = $(currentElement).data("title-url");
        if (titleUrl) {
            var link = $("<a>", {href: titleUrl, text: titleUrl, target: "_blank"});
            html += " (" + link.prop("outerHTML") + ")";
        }

        return html;
    },
}

http://fancybox.net/apiする

http://api.jquery.com/data/する

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top