小编use*_*587的帖子

设置 div 的值 contenteditable=true

给定一个带有 的 div contenteditable=true,如何向元素添加文本?

<div aria-autocomplete="list" contenteditable="true" role="textbox" spellcheck="true">

</div>
Run Code Online (Sandbox Code Playgroud)

我已经尝试过document.activeElement.value,但由于它是一个 div 我无法设置该值

html javascript

5
推荐指数
1
解决办法
9505
查看次数

从0.10升级到版本0.11时,Angular UI引导程序日期选择器弹出窗口不起作用

升级到版本0.11后单击时,不会弹出angular-ui-bootstrap日期选取器.

我已经尝试了推荐的工作设置

is-open="dt.open" ng-focus="dt.open=true"
Run Code Online (Sandbox Code Playgroud)

只有在一个日历上启用它时才有效,但如果在同一页面上有两个日历,则无效(打开且无法使用).任何人都知道更好的工作,不污染范围?

我也尝试将ng-focus更改为ng-click,并且没有运气.

datepicker angularjs angular-ui-bootstrap

4
推荐指数
1
解决办法
4779
查看次数

Rails使所有路由默认格式为:: json

你能默认所有路线json吗?

我有以下api范围,但我想知道你是否可以在全球范围内做同样的事情?

  scope :api, defaults: {format: :json} do
    get "/search(/:query)(/:location)" => "search#index"
  end
Run Code Online (Sandbox Code Playgroud)

例如,所有user资源也将默认为json

resources :users
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

4
推荐指数
1
解决办法
6134
查看次数

Rails 路由约束未按预期工作

我今天早些时候问了这个关于将所有路由包装成默认 json 格式的问题。我本可以发誓它更早地工作,但我可能弄错了。

这是怎么工作的:

resources :insurances, only: [:index, :show], :defaults => { :format => 'json' }
Run Code Online (Sandbox Code Playgroud)

但这不会:

constraints format: :json do
  resources :insurances, only: [:index, :show]
end
Run Code Online (Sandbox Code Playgroud)

我是否缺少有关约束如何工作的基本知识?

ruby-on-rails

4
推荐指数
1
解决办法
1880
查看次数

SQL中的求和计算值

我有两个 SELECT 语句想要求和。两个查询都工作正常,但我无法对总计的输出进行求和。我尝试遵循这个问题,但无法通过将查询包装在中来求和select id, sum(amount) from ( )

SELECT "patient_profiles"."id", count(distinct recommendations.id) AS total
FROM "patient_profiles" 
  LEFT OUTER JOIN 
  "recommendations" ON "recommendations"."patient_profile_id" = "patient_profiles"."id" 
GROUP BY "patient_profiles"."id"

UNION

SELECT "patient_profiles"."id", count(distinct patient_profile_potential_doctors.id) AS total
FROM "patient_profiles" 
  LEFT OUTER JOIN "patient_profile_potential_doctors" ON "patient_profile_potential_doctors"."patient_profile_id" = "patient_profiles"."id"       
GROUP BY "patient_profiles"."id"
Run Code Online (Sandbox Code Playgroud)

sql postgresql join left-join

4
推荐指数
1
解决办法
4791
查看次数

将字节或base64字符串上传到s3 ruby​​ sdk

我正在尝试使用ruby aws sdk将图像上传到s3.如果我没有设置content_type,我可以上传base64字符串.如果我将content_type设置image/png为上传只是通用图像缩略图.

obj = #<Aws::S3::Object bucket_name="mybucket", key="test">

>> params[:file]
>> "data:image/png;base64,iVB...."

obj.put(body: params[:file], content_type: 'image/png', content_encoding: 'base64')
Run Code Online (Sandbox Code Playgroud)

如何将Base64字符串上传到s3?如果更直接的话,我也愿意上传为字节

ruby amazon-s3 amazon-web-services

3
推荐指数
1
解决办法
1007
查看次数

algolia facets在javascript API客户端中返回空对象

我正在使用Javascript API 客户端,并希望在我的索引上返回facet.我相信为索引打开了faceting因为1.我在UI 2中切换了开关.我可以在仪表板中使用faceting作为索引.我使用以下参数设置我的索引:

var params = {
  tagFilters: 'query',
  aroundLatLngViaIP: true,
  getRankingInfo: 1,
  facets: "*"
};
Run Code Online (Sandbox Code Playgroud)

但是,这会返回一个空的facets对象.如何通过所有可能的分面选项接收构面对象?

的jsfiddle

algolia

3
推荐指数
1
解决办法
239
查看次数

JavaScript正则表达式删除完美匹配上的任何前缀

如何在字符串中删除"Dr","Dr."或"dr"?

"Dr. Drake Cohen" would become "Drake Cohen"
"Dr Drake Cohen" would become "Drake Cohen"
"Drake Cohen" would become "Drake Cohen"
"Rachel Smith" would become "Rachel Smith"
"Dr. Rachel Smith" would become "Rachel Smith"
Run Code Online (Sandbox Code Playgroud)

我尝试过的:

str.replace(/dr./i, "")
Run Code Online (Sandbox Code Playgroud)

但这会删除Dr.的所有实例

javascript regex

3
推荐指数
1
解决办法
514
查看次数

文本位于下方 div 边框顶部

我想让文本出现在 div 的顶部,该 div 的边框也有白色背景,这样您就不会看到边框线穿过文本。我尝试在文本中添加 z-index 但我相信position: relative这并不重要。我也愿意接受有关如何完成的其他建议,并且不想使用 afieldsetlegend

小提琴

#large-div-text {
  padding: 20px;
  border: 1px solid rgba(64, 189, 233, 0.42);
  position: relative;
  margin-top: -10px;
}

#why {
  background-color: #FFF;
  text-align: center;
  z-index: 1000;
}
Run Code Online (Sandbox Code Playgroud)
<div id="why">
  No line behind me, please!
</div>
<div id="large-div-text">
  Large div text
</div>
Run Code Online (Sandbox Code Playgroud)

html css

3
推荐指数
1
解决办法
1444
查看次数

嵌套的flexbox对齐项将特定内容居中

我正在尝试构建下面的简单表格。

在此处输入图片说明

我正在使用flexbox,但无法正确对齐textarea。align-items: center对齐整个div。我尝试将textarea div取出,并且在将textarea相对于上述flexbox容器对齐时遇到麻烦。在将x,照片,名称和对齐方式居中的同时,如何实现上述文本框的位置。

小提琴

.container {
  display: flex;
}
.content {
  flex-grow: 1;
}
textarea {
  width: 100%;
}
img {
  border-radius: 30px;
  margin: 0 10px;
}
Run Code Online (Sandbox Code Playgroud)
<div class="container">
  <div>
    x
  </div>
  <div>
   <img src="http://via.placeholder.com/50x50">
  </div>
  <div class="content">
    <div>Brad</div>
    <div>Boston</div>
    <textarea></textarea>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css css3 flexbox css-grid

3
推荐指数
1
解决办法
301
查看次数