简体   繁体   English

Javascript在Spotfire Webplayer中的行为有所不同

[英]Javascript behaves differently in Spotfire Webplayer

I implemented some functionality where the user can filter the data using input fields and a dropdown menu. 我实现了一些功能,用户可以使用输入字段和下拉菜单过滤数据。

So a user can select an item form this list (eg Last ... Days or Select Date Range) and then input the numbers/dates in input fields. 因此,用户可以从该列表中选择项目(例如,上次...天或选择日期范围),然后在输入字段中输入数字/日期。 The script is then used to show the corresponding input field and hide the rest. 然后,该脚本用于显示相应的输入字段并隐藏其余字段。 EDIT: Last week I got updated to Spotfire 7.5 from 7.0. 编辑:上周我从7.0更新到Spotfire 7.5。 Now this script does not work on the desktop client either.... 现在这个脚本无法在桌面客户端上运行....

本地

This is what I get in the webplayer: 这是我在网络播放器中得到的: Web播放器

Any idea as to why this happens? 知道为什么会这样吗? This is my HTML: 这是我的HTML:

Select Period:<span id="PeriodSelector"><SpotfireControl id="306fdd699c4346dbb7265c1d101fa6cf" /></span >
<span id="SelectBeginDate" style ="padding-left:1em;" > Select Begin Date:<SpotfireControl id="16b0eab3d5e3497bb2ecea3b051d2b62" /></span >
<span id="SelectEndDate" style = "padding-left:1em;">   Select End Date:<SpotfireControl id="46ac3d97e3b04af182b8b9d2462a7d27" /></span >
<span id="SelectDate"style = "padding-left:1em;">   Select Date:<SpotfireControl id="6838924384aa4567bc3bcf9da5a74c32" /></span >
<span id="LastXDays" style = "padding-left:1em;">   Number of Days:<SpotfireControl id="218b27e83771401dbbd75613acfd619b" /></span >

And this is my script: 这是我的脚本:

$("#306fdd699c4346dbb7265c1d101fa6cf").change(function() {
    var valueText = $("#306fdd699c4346dbb7265c1d101fa6cf option:selected").text();
    if(valueText ==="Select Date"){
        $("#SelectDate").css('display','inline');
        $("#SelectBeginDate").css('display','none');
        $("#SelectEndDate").css('display','none');
        $("#LastXDays").css('display','none');
    } else if (valueText ==="Select Date Range"){
        $("#SelectDate").hide();
        $("#SelectBeginDate").css('display','inline');
        $("#SelectEndDate").css('display','inline');
        $("#LastXDays").css('display','none');
    } else if (valueText ==="Select  Last … Days"){
        $("#SelectDate").css('display','none');
        $("#SelectBeginDate").css('display','none');
        $("#SelectEndDate").css('display','none');
        $("#LastXDays").css('display','inline');
    } else {
        $("#SelectDate").css('display','none');
        $("#SelectBeginDate").css('display','none');
        $("#SelectEndDate").css('display','none');
        $("#LastXDays").css('display','none');
    }
});

It seems that the webplayer does not retrieve the value of the dropdown box, but I have no clue as to why it doesn't. 似乎网络播放器没有检索下拉框的值,但我不知道它为什么没有。

Any help is deeply appreciated. 非常感谢任何帮助。

So after contact with Tibco Support it seems that indeed the .change() function is not supported. 因此,在与Tibco支持联系之后,似乎确实不支持.change()函数。

In Spotfire 7.5 the property controls are no longer implemented using the standard JavaScript input types like the select tag for instance. 在Spotfire 7.5中,不再使用标准JavaScript输入类型(例如select标签)实现属性控件。 In 7.5 the controls are now implemented using a series of div tags instead and they do not have any "change" event to trigger on. 在7.5中,控件现在使用一系列div标签来实现,而且它们没有任何“更改”事件可以触发。

Manipulating controls or adding events using JavaScript/JQuery is not supported since they are subject to change. 不支持使用JavaScript / JQuery操作控件或添加事件,因为它们可能会发生变化。 It is adviced to use JavaSript for only manipulating HTML. 建议使用JavaSript来仅操作HTML。 If a workaround is needed it is possible to create input controls and poplulate them using JS. 如果需要解决方法,可以创建输入控件并使用JS弹出它们。

That being said, I did find a workaround using setInterVal(). 话虽这么说,我确实找到了使用setInterVal()的解决方法。 The code is identical as my original post - except I use a hidden Calculated Value in the textfield to write the value in the document property to. 代码与我的原始帖子完全相同 - 除了我在文本字段中使用隐藏的计算值来将文档属性中的值写入。

......

setInterval(
function(){
    ...........
    var valueText= document.getElementById("Hidden").textContent;
    ...........
}, 1000);

where Hidden is a span/div containing the Calculated Value. 其中Hidden是包含计算值的span / div。 Hope this helps 希望这可以帮助

I don't know enough about javascript to tell you WHY, but based on my testing and using this link as an example, this code may work for you: 我不太了解javascript告诉你为什么,但根据我的测试并使用此链接作为示例,此代码可能适合您:

$("#306fdd699c4346dbb7265c1d101fa6cf").change(function() {
     $("option:selected",this).text()=="Select Date"?
      $("#SelectDate).fadeIn() & $("#SelectBeginDate").fadeOut() & $("#SelectEndDate").fadeOut() & $("#LastXDays").fadeOut():
      $("option:selected",this).text()=="Select Date Range"?
       $("#SelectDate).fadeOut() & $("#SelectBeginDate").fadeIn() & $("#SelectEndDate").fadeIn() & $("#LastXDays").fadeOut():
       $("option:selected",this).text()=="Select  Last … Days"?
        $("#SelectDate).fadeOut() & $("#SelectBeginDate").fadeOut() & $("#SelectEndDate").fadeOut() & $("#LastXDays").fadeIn():
        $("#SelectDate).fadeOut() & $("#SelectBeginDate").fadeOut() & $("#SelectEndDate").fadeOut() & $("#LastXDays").fadeOut()

})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM