我想让facebook分享插件并运行.我遇到的问题是我必须重新加载页面以实际显示共享按钮.如果我通过链接或网址导航到页面,Facebook分享按钮将不会显示,我必须重新加载页面,然后按钮将显示.我正在使用角度因此想到使用指令,但到目前为止我的努力还没有成功.
这是我在模板中有指令的地方
<div class="fb-share-button" fb-share data-href="{{fbUrl}}" data-layout="button" id='fb-share'></div>
Run Code Online (Sandbox Code Playgroud)
这是我的指示.
angular.module('App').directive('fbShare', function () {
function createHTML(href, layout) {
return '<div class="fb-share-button" ' +
'data-href="' + href + '" ' +
'data-layout="' + layout + '" ' +
'</div>';
}
return {
restrict: 'A',
scope: {},
link: function postLink(scope, elem, attrs) {
attrs.$observe('dataHref', function (newValue) {
var href = newValue;
var layout = attrs.layout || 'button';
elem.html(createHTML(href, layout));
FB.XFBML.parse(elem[0]);
});
}
};
});
Run Code Online (Sandbox Code Playgroud)
facebook sdk代码就在开放的body标签之后
<div id="fb-root"></div>
<script>(function(d, s, id) {
var …Run Code Online (Sandbox Code Playgroud) 我试图在我的表单中使用角形式验证作为博客文章,更具体地说是禁用ng表格.由于我无法弄清楚提交按钮没有被禁用的原因,除非所有三个输入字段都有效,否则它应该在哪里.谢谢您的帮助.
这是我的博客模板
<div ng-controller='BlgoCtrl'>
<div class='container'>
<h1> Teewinot Blgo</h1>
<div class="row">
<div class='col-md-12'>
<form role='form' name='blgoPost' novalidate>
<div class='form-group'>
<label for='blgoTitle'>Title</label>
<input name='title' type="title" class='form-control' placeholder='Technologies of the Future' required><br>
<label for='blgoContent'>Content</label>
<textarea name='content' rows='8' type="content" class='form-control' placeholder='The technical innovations of the future will be diverse and impactful on the individual......' required></textarea><br>
<label for='blgoPassCode'>PassCode</label>
<input name='passcode' type="passcode" class='form-control' placeholder='•••••••••••••••' required><br>
<button type="submit" class='btn btn-primary' ng-disabled="blgoPost.$invalid">Submit Post</button>
</div>
</form>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Teewinot</title>
<script …Run Code Online (Sandbox Code Playgroud) 我想使用 github api/Octokit 检查功能分支是否已合并到我的主分支中。我无法找到有关此主题的任何文档或帖子。这可能吗?有没有人知道任何关于这个主题的帖子?
使用 ruby rails 'binding.pry' 时跳过一行代码的终端命令是什么?另外你知道进入、退出和继续的命令吗?
下面是一个例子:
def add_nums
x = 5 + 5
binding.pry
x += 5
x += 7
return x
end
Run Code Online (Sandbox Code Playgroud)
我想知道如何逐步执行此方法并在我的终端中查看 'x' 的值,直到它返回为止。谢谢
我试图从模型中调用时获取特定表的所有记录及其关联数据.我尝试了很多不同的选择,但似乎无法弄明白.
我有一个rails结构,其中:(假设所有类都继承自activerecord:base)
class Post
has_many :image
has many :comment
end
class Image
belongs_to :post
end
class Comment
belongs_to :post
end
Run Code Online (Sandbox Code Playgroud)
基本上我想在Post类(或模型)中获取包含所有相关数据的所有帖子.例如:
Post.all (but then here do something to include each post's images and comments)
Run Code Online (Sandbox Code Playgroud)
我已经尝试了这两个选项,但他们没有返回相关数据
Post.all.eager_load(:image, :comment)
Blog2.all.includes(:image, :comment)
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我有一个索引方法
def index
@posts = Post.all
render json: @posts, :include => [:image, :comment]
end
Run Code Online (Sandbox Code Playgroud)
这个索引方法工作得很完美,并且包含了与每条记录相关的数据,但是当我尝试在模型中获取所有帖子及其相关数据时,我无法开始工作.谢谢您的帮助
我无法关闭我的引导警报.我在引导程序之前声明了我的jquery,警报仍未关闭.警报的代码如下.有任何想法吗?
<!-- jquery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Yay</strong> Your email has been added!
</div>
Run Code Online (Sandbox Code Playgroud) 我试图让我的rails form_for提交按钮看起来像引导btn btn-lg btn-primary按钮.我尝试了几种不同的方法,却没有成功.我能得到的最好的方法是将form_for提交按钮放在具有不同颜色的自举按钮的中心.有谁知道命令是什么让引导按钮执行我的f.submit按钮所做的操作.
<div class="Action">
<%= f.submit %>
</div>
Run Code Online (Sandbox Code Playgroud) angularjs ×2
javascript ×2
ruby ×2
facebook ×1
forms ×1
github ×1
github-api ×1
html ×1
jquery ×1
octokit.net ×1
pry ×1
validation ×1