我在页面中嵌入了以下JS:
var round = Math.round;
var id = $(this).attr("id");
var len = id.length;
var indexPos = len -1; // index of the number so that we can split this up and used it as a title
var pasType = id.substring(0, indexPos); // adult, child or infant
var ind = round(id.substring(indexPos)); // converts the string index to an integer
var number = (id.substring(indexPos) + 1); // creates the number that will go in the title
window.alert(number);
Run Code Online (Sandbox Code Playgroud)
id 将是像adult0一样的东西,我需要把它串起来分成成人和0 - 这部分工作正常.
当我尝试增加0时出现问题.正如您所看到的,我使用Math.round将其转换为整数,然后将其加1 …
这个问题是密切相关的这一个(已回答).
在整个项目中,我使用JSF命令按钮在屏幕之间导航,其中action属性指向返回字符串的函数.字符串是新屏幕的名称,例如
<h:commandButton value="Select" action="#{searchResultsBundledBean.selectFlight}">
</h:commandButton>
Run Code Online (Sandbox Code Playgroud)
selectFlight将返回一个字符串,例如selected-flight-review,它将指导用户selected-flight-review.xhtml
出于移动目的,我必须panelGrid使用ajax调用进行可点击,例如
<h:panelGrid>
<f:ajax event="click" listener="#{searchResultsBundledBean.clickFlight(lowFareBundledSearchItem)}"/>
</h:panelGrid
Run Code Online (Sandbox Code Playgroud)
这是有效的,我已经测试过,并且返回了正确的结果(在返回之前进行了测试)
但是,不会发生重定向.ajax调用尚未执行此操作.如何将其重定向到另一个屏幕?我不需要通过任何变量发送,我只需要显示新的屏幕.我应该使用除ajax以外的东西(我不愿意),还是有某种方法可以按照现在的方式使用它?
我在html文件中包含以下内容:
<h:outputStylesheet name="css/bootstrap.css" />
<h:outputScript name="js/jquery-2.0.2.min.js" />
<h:outputScript name="js/bootstrap-tooltip.js" />
<h:outputScript name="js/bootstrap-popover.js" />
Run Code Online (Sandbox Code Playgroud)
应该制作弹出窗口的部分:
<ui:repeat var="lowFareCalenderSearchItem" value="#{lowFareCalenderSearchItems}">
<td>
<a href="#" id="searchItem" class="btn" rel="popover">#searchResult.getTotal()}</a>
<script>
$("#searchItem").popover({
title: "title",
content: "content"
});
</script>
</td>
</ui:repeat>
Run Code Online (Sandbox Code Playgroud)
当我将鼠标悬停在上面或单击按钮时,我试图显示的弹出窗口不会出现.
我已经看过其他类似的问题了,我发现没有什么对我有用.
有谁知道为什么会发生这种情况?
我已经设法创建了一个有效的twitter类型ajax调用.
打字太快时,我遇到了重复项目的问题.
示例场景:
当你试图获得"Casablanca"时,你会开始打字,并期望当你达到"casa"时它会被相对很好地过滤掉.不幸的是这些项目是重复的,所以我不会有2或3个选项,而是会有9到20个D:
这是正在进行调用的JS:
$(".airportSearch").typeahead({
source: function(query, process) {
airports = [];
map = {};
$.ajax({
url: url_,
dataType: "json",
data: {
n: 12, q: query
},
success: function(data) {
$.each(data, function (i, record) {
map[record.airport] = record;
airports.push(record.city + ", " + record.airport + " (" + record.iata + "), " + record.country);
});
process(airports);
}
});
},
minLength: 1,
items: 11,
sorter: function (items) {
return items.sort();
},
updater: function (item) {
selectedState = map[item].iata;
return item; …Run Code Online (Sandbox Code Playgroud) 我有一个<h:panelGroup>带有rendered属性的标签。它调用以确定它是否呈现的函数返回 true,我已经记录并打印了这一点以确保。
结构如下:
<h:form>
<div><!-- content --></div>
<h:panelGroup>
<h:panelGroup rendered="#{bean.function(parameter)} == true">
<!-- content -->
</h:panelGroup>
<h:panelGroup>
</h:form>
Run Code Online (Sandbox Code Playgroud)
即使函数返回 true,带有渲染标签的 panelGroup 也永远不会显示。知道为什么这不起作用吗?
我正在使用需要转换为java.util.date对象的日期字符串.
我正在使用以下代码执行此操作:
public void setDates(String from, String to) throws ParseException
{
Date fromDate = new Date();
Date toDate = new Date();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
fromDate = df.parse(from);
toDate = df.parse(to);
this.setDepartDate(fromDate);
this.setReturnDate(toDate);
}
Run Code Online (Sandbox Code Playgroud)
问题是我必须转换的字符串值总是(我无法控制),格式如下:"2013年9月20日".
这会导致我的函数在到达时通过ParseException fromDate = df.parse(from);
任何人都可以帮助我理解为什么,也许建议一个解决方案?