<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
在html文件的顶部.
我试过了
//[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]
//[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]
//[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]
//[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]
head …Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的d3可视化中使用angularjs 工具提示指令,所以我有类似的东西
var node = svg.selectAll(".node")
.data(nodes)
.enter().append("circle")
.attr("tooltip-append-to-body", true)
.attr("tooltip", function(d) {
return d.name;
})
// ... attributes
Run Code Online (Sandbox Code Playgroud)
但是,工具提示未显示.我需要$compile什么?我也试过把它包裹起来$timeout,但那不起作用.
我试图在我的sinatra应用程序(更具体地说,一个padrino应用程序)的主页上测试重定向,在rspec中.我发现redirect_to,但它似乎只在rspec-rails中.你如何在sinatra中测试它?
所以基本上,我喜欢这样的东西:
it "Homepage should redirect to locations#index" do
get "/"
last_response.should be_redirect # This works, but I want it to be more specific
# last_response.should redirect_to('/locations') # Only works for rspec-rails
end
Run Code Online (Sandbox Code Playgroud) 我想从文件加载一个html页面,并为其添加一个哈希标记.这可能吗?
我试过了
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];
NSURL *fileUrl = [NSURL fileURLWithPath:[filePath stringByAppendingFormat:@"#hashtag"]];
[self.webView loadRequest:[NSURLRequest requestWithURL:fileUrl]];
NSLog(@"fileUrl = %@, reachable? %d", fileUrl, [fileUrl checkResourceIsReachableAndReturnError:nil]);
Run Code Online (Sandbox Code Playgroud)
但这会尝试查找someFile.html%23hashtag无法找到的文件.有没有办法在NSURL创建对象后添加哈希?
我也尝试将文件加载到字符串中并使用loadHTMLString:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someFile" ofType:@"html"];
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
[self.webView loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://someFile.html#hashtag"]];
Run Code Online (Sandbox Code Playgroud)
这里的哈希标签确实有效,但我在html中的javascript引用不起作用.这个方法的后续问题是,如何从UIWebView中作为字符串加载的html引用javascript文件,即什么是基本URL?
我能想到的一个黑客就是将我的所有javascript文件内联到html中并将其加载为字符串,但我认为必须有更好的方法!
我是骨干的新手,并试图在Sinatra中设置它,但我似乎无法让简单的创建工作.
我已经设置了我的模型/集合:
var TEAM_ID = window.location.pathname.split('/')[1]; // From url
$(function () {
var TeamMember = Backbone.Model.extend({
defaults: {
name : ""
}
});
var TeamMembers = Backbone.Collection.extend({
model: TeamMember,
url: "/" + TEAM_ID + "/team-members.json"
});
var teamMembers = new TeamMembers;
var TeamMemberView = Backbone.View.extend({
events: {
"click #new-team-member-form .submit-button" : "handleNewTeamMember"
},
handleNewTeamMember: function(data) {
var inputField = $('input[name=new_team_member_name]');
console.log("Pre create");
// This doesn't get sent to the server!!
var teamMember = teamMembers.create({name: inputField.val());
console.log("Post create");
return false; // …Run Code Online (Sandbox Code Playgroud) 我正在尝试重构我的sinatra代码,将我的主文件分成单独的文件,使用此响应中的一些提示,我遇到了部署到heroku的麻烦.
以前我没有config.ru文件,只是使用了我的Procfile,这是:
web: bundle exec ruby web.rb -p $PORT
Run Code Online (Sandbox Code Playgroud)
根据这篇文章.
从重构开始,我现在改变了我Procfile的意思
web: bundle exec thin -R config.ru start -p $PORT
Run Code Online (Sandbox Code Playgroud)
随着我的config.ru文件正在
root = ::File.dirname(__FILE__)
require ::File.join( root, 'web' )
run MyApp.new
Run Code Online (Sandbox Code Playgroud)
我的web.rb文件包含在类定义中
class MyApp < Sinatra::Application
# ...
end
Run Code Online (Sandbox Code Playgroud)
这适用于我的本地开发计算机,但是当我部署到heroku时,我得到了
2011-12-01T11:21:54+00:00 app[web.1]: bundler: command not found: thin
2011-12-01T11:21:54+00:00 app[web.1]: Install missing gem executables with `bundle install`
2011-12-01T11:21:56+00:00 heroku[web.1]: State changed from starting to crashed
2011-12-01T11:22:01+00:00 heroku[router]: …Run Code Online (Sandbox Code Playgroud) 我正在使用来自apple的Touches代码的略微改编的代码(我刚刚将片段的变量名称更改为图像):
- (void)adjustAnchorPointForGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
UIView *image = gestureRecognizer.view;
CGPoint locationInView = [gestureRecognizer locationInView:image];
CGPoint locationInSuperview = [gestureRecognizer locationInView:image.superview];
// Gives error: Property 'anchorPoint' not found on object of type 'CALayer *'
//image.layer.anchorPoint = CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height);
// Gives warning: Method '-setAnchorPoint' not found
[image.layer setAnchorPoint:CGPointMake(locationInView.x / image.bounds.size.width, locationInView.y / image.bounds.size.height)];
image.center = locationInSuperview;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,如注释中所述,image.layer.anchorPoint无法编译,但错误是无法找到'anchorPoint'属性.它在使用消息传递重写行时进行编译,但它仍会发出警告.
直接复制和粘贴Touches代码而不更改名称更改会产生相同的错误.编译Touches代码时也不会出现这些错误.
为什么是这样?
我有一个Sinatra应用程序,使用omniauth,不断得到这个错误
attack prevented by Rack::Protection::SessionHijacking
Run Code Online (Sandbox Code Playgroud)
当我尝试登录时(使用谷歌帐户).
它在其他版本的IE和chrome/firefox/safari上运行良好.
我的设置是
rack (1.4.1)
rack-force_domain (0.2.0)
rack-protection (1.2.0)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
omniauth (1.0.3)
hashie (~> 1.2)
rack
omniauth-google-oauth2 (0.1.9)
omniauth (~> 1.0)
omniauth-oauth2
omniauth-oauth2 (1.0.0)
oauth2 (~> 0.5.0)
omniauth (~> 1.0)
Run Code Online (Sandbox Code Playgroud)
谁知道为什么会这样?
我创建了一个Env包装环境信息的服务,我目前正在使用它$location.host()来确定我所处的环境.如何在我的测试中模拟它?
我已阅读https://groups.google.com/forum/?fromgroups#!topic/angular/F0jFWC4G9hI,但它似乎不起作用,例如:
describe("Env (environment) service", function() {
var Env;
beforeEach(module('App'));
beforeEach(inject(
['Env', function(e) {
Env = e;
}]
));
describe("for staging", function() {
beforeEach(inject(function($location, $rootScope) {
$location.host("http://staging-site.com");
$rootScope.$apply();
}));
it("returns envrionment as staging", function() {
expect(Env.environment).toEqual("staging");
});
it("returns .isStaging() as true", function() {
expect(Env.isStaging()).toBeTruthy();
});
});
});
Run Code Online (Sandbox Code Playgroud)
我也试过了这个$browser变种,但这也行不通.有任何想法吗?
这与stackoverflow上的其他几个问题非常相似,但它们似乎都来自去年并且指的是较低的版本号.
我有:
没有太多运气,我尝试了以下内容:
我确定iOS 4.2现在应该没有测试版,所以我认为这也不是问题.还有其他想法吗?有没有办法获得有关苹果想要的SDK版本的更多信息?
确实非常令人沮丧!
sinatra ×4
ios ×3
iphone ×3
angularjs ×2
ruby ×2
angular-ui ×1
app-store ×1
backbone.js ×1
d3.js ×1
deployment ×1
heroku ×1
html ×1
ios4 ×1
javascript ×1
mocking ×1
node.js ×1
objective-c ×1
omniauth ×1
padrino ×1
pug ×1
rack ×1
rspec ×1
testing ×1
uiview ×1
uiwebview ×1