Yo'qotilgan Facebook kabi tugmani qanday disk raskadrovka qila olaman?

JQuery-dan foydalanib, sahifaga Like Button va Dushanba tugmasi ni qo'shishga harakat qilaman. Dushanba tugmasi juda yaxshi ishlaydi, lekin Like Button ko'rinmaydi. Nima noto'g'ri ekanini bilmayman, lekin bundan ham yomoni, hech qanday xatolik yoki muammoga ishora qiluvchi xabarlar yo'q.

Qanday qilib men Facebook-ni, Firebugni yoki boshqa narsalarni yo'qotishimni aytmoqchiman yoki xatoga yo'l qo'yyapmanmi?

Bu erda jsfiddle'da namoyish qilish .

Bu erda jsfiddlega bormoqchi bo'lmaganlar uchun to'liq kod bor:

/**
 * Generate the container elements for social media stuff.
 */
$(function generateSocMedElements($) {
    var id = "socmed",
        $container,
        $fb_root,
        $fb_like,
        $tweet_button;
    if ($("#" + id).length <= 0) {
        $container = $(document.createElement("aside")).
            addClass("socmed").
            attr("id", id);
        $fb_root = $(document.createElement("div")).attr("id", "fb-root");
        $fb_like = $(document.createElement("div")).
            addClass("fb-like").
            attr("data-href", "example.org").
            attr("data-send", "false").
            attr("data-layout", "button_count").
            attr("data-width", 82).attr("data-show-faces", "false");
        $tweet_button = $(document.createElement("a")).
            addClass("twitter-share-button").
            attr("href", "//twitter.com/share").
            attr("data-count", "none").
            text("Tweet");
        $container.
            appendTo($("header").first()).
            append($fb_root).
            append($fb_like).
            append($tweet_button);
    }
});

/**
 * Load the script for the Facebook API.
 */
$(function loadFacebook($) {
    var id = "facebook-jssdk";
    if ($("#" + id).length <= 0) {
        $(document.createElement("script")).
            attr("id", id).
            attr("src", "//connect.facebook.net/en_US/all.js").
            appendTo("head");
    }
});

/**
 * Load the script for the Twitter API.
 */
$(function loadTwitter($) {
    var id = 'twitterSdk';
    if ($("#" + id).length <= 0) {
        $(document.createElement("script")).
            attr("id", id).
            attr("src", "//platform.twitter.com/widgets.js").
            appendTo("head");
    }
});
3
@CalebGray Like va Dushanba tugmalari bu skript ishlayotgan paytda mavjud bo'lmasligi kerak, lekin men buni amalga oshirish uchun chekni tashladim. Tugma va shunga o'xshash tugmalar sahifada birinchi header elementiga qo'shilgan chetga elementi sifatida ko'rinishi kerak.
qo'shib qo'ydi muallif kojiro, manba
@ShawnECarter Ha, men ham buni ko'rdim. Lekin Firebug hali skriptni yuklangan skriptlar ro'yxatida tanib turadigan ko'rinadi. Skript o'z-o'zidan biroz xo'rozsiz sabablarga ko'ra o'chiradimi?
qo'shib qo'ydi muallif kojiro, manba
Tabiiyki, "Missing Facebook Like tugmacha tuzatuvchisining Visual Studio 2010 uchun" ni foydalanib, yo'qolgan facebook kodi kabi tugmachasini disk raskadrovka qilish kerak.
qo'shib qo'ydi muallif Camilo Martin, manba
js fiddle da all.js ning ba'zi sabablarga ko'ra eklanmaganiga o'xshaydi. Men bu bilan bir oz o'ynashni davom ettiraman va biron bir natija bilan orqaga qaytaman. Men hozirda shunga o'xshash tugmani iframe versiyasidan foydalanishni taklif qilaman.
qo'shib qo'ydi muallif Shawn E Carter, manba
Ushbu kod bilan aniq nimaga erishmoqchisiz? Aytishim mumkinki, siz tugmalarni dinamik ravishda yuklashga urinmoqdasiz ... lekin siz "#" va "id" ni elementlarni tanlash uchun ishlatasiz, lekin "addClass" dan foydalanishingiz mumkin. Sahifadagi "Like" va "Dushanba" havolalarini topishga harakat qilyapsizmi va ularni dinamik ravishda yaratilgan tugma bilan almashtirasizmi?
qo'shib qo'ydi muallif Caleb Gray, manba

1 javoblar

http://jsfiddle.net/ShawnsSpace/btN89/3/ i was able to get it to work by

  1. head tagidagi div tegini qo'shish
  2. funktsiyani yaratish va sahifa yukidan keyin qidirishni bajarishSocMedElements() ni ishlab chiqarish.
  3. Facebook html5 skriptini ishlatgan.

. Sizga kerakli ko'rinishni olish uchun uni tweek qilishingiz kerak bo'ladi.

OH HAI I HAZ A HEADER

<div id="fb-root"></div>

/**
 * Load the script for the Facebook API.
 */

(function(d, s, id) {
  var JS, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  JS = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


/**
 * Load the script for the Twitter API.
 */
$(function loadTwitter($) {
    var id = 'twitterSdk';
    if ($("#" + id).length <= 0) {
        $(document.createElement("script")).
            attr("id", id).
            attr("src", "//platform.twitter.com/widgets.js").
            appendTo("head");
    }
});
function loadthis($){
$(function generateSocMedElements($) {
    var id = "socmed",
        $container,
        $fb_root,
        $fb_like,
        $tweet_button;
    if ($("#" + id).length <= 0) {
        $container = $(document.createElement("aside")).
            addClass("socmed").
            attr("id", id);
        $fb_root = $(document.createElement("div")).attr("id", "fb-root");
        $fb_like = $(document.createElement("div")).
            addClass("fb-like").
            attr("data-href", "example.org").
            attr("data-send", "false").
            attr("data-layout", "button_count").
            attr("data-width", 82).attr("data-show-faces", "false");
        $tweet_button = $(document.createElement("a")).
            addClass("twitter-share-button").
            attr("href", "//twitter.com/share").
            attr("data-count", "none").
            text("Tweet");
        $container.
            appendTo($("header").first()).
            append($fb_root).
            append($fb_like).
            append($tweet_button);
    }
});
}
loadthis($);
4
qo'shib qo'ydi
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb