public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            //class="nsyte" id="6Fg3Aj9GzNw" data-width="480" data-height="360">
            output.TagName = "";

            _scriptManager.AddScript(new ScriptReference("/js/jquery.nonSuckyYouTubeEmbed.js", 1000));

            var uniqueVal = Guid.NewGuid().ToString("D");

            // add guid to .nyste (same for all, global guid)
            var sb = new StringBuilder();

            sb.AppendFormat
                ("<div  id=\"nsyte-{0}\" youtubeid=\"{1}\" \"></div>",
                uniqueVal, YouTubeId);


            var scriptTextExecute = string.Format(@"
                 $(document).ready(function () {{
                        $('#nsyte-{0}').nonSuckyYouTubeEmbed();
                }});
            ", uniqueVal);

            _scriptManager.AddScriptText(scriptTextExecute);

            output.Content = output.Content.SetHtmlContent(sb.ToString());
        }
예제 #2
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            _scriptManager.AddScript(
                new ScriptReference("https://code.jquery.com/jquery-1.10.2.min.js", 1000));
            _scriptManager.AddScript(
                new ScriptReference("/js/jquery.nonSuckyYouTubeEmbed.js", 1000));
            output.Attributes.Add(new TagHelperAttribute("youtubeid", YouTubeId));
            output.Attributes.Add(new TagHelperAttribute("class", "nsyte"));

            var scriptTextExecute = string.Format(@"
                 $(document).ready(function () {{
                        $('.nsyte').nonSuckyYouTubeEmbed();
                }});
            ");

            _scriptManager.AddScriptText(scriptTextExecute);
        }