2

我正在尝试创建一个将数据存储在一系列可折叠菜单中的应用程序。首先有一个月菜单,然后是月内的天,然后是天内的时间,然后是时间内的数据。我需要菜单的标题能够根据用户输入的时间和日期进行更改,但是如果我更改标题文本,菜单会丢失其图形并变成文本。点击它会显示可折叠的内容,但不会触发可折叠的 onclick 事件。给出的大部分 html 代码都是由 Codiqa 生成的。我怎样才能使这项工作正确?

可折叠的html页面:

<!-- Logs -->
    <div data-role="page" data-theme="a" id="page15">
        <div data-theme="a" data-role="header">
            <h3>
                Logs
            </h3>
            <a data-role="button" data-direction="reverse" data-transition="slide" href="#page3" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left">
                Back
            </a>
        </div>
        <div data-role="content" style="padding: 15px">
            <a data-role="button" data-transition="slide" href="#page1">
                Add log entry
            </a>
            <div data-role="collapsible-set" data-theme="" data-content-theme="">
                <div data-role="collapsible" data-collapsed="true">
                    <h3>
                        July 2012
                    </h3>
                    <div data-role="collapsible-set" data-theme="" data-content-theme="">
                        <div data-role="collapsible" data-collapsed="true" onclick="getLogTime(); this.onclick=null">
                            <h3>
                                July 5
                            </h3>
                            <div data-role="collapsible-set" data-theme="" data-content-theme="">
                                <div data-role="collapsible" data-collapsed="true" onclick="getLogData(); this.onclick=null">
                                    <h3 id=time1>//Heading in question
                                    </h3>
                                    <div>
                                        <p id="logFortime1">
                                        Log 1
                                        </p>
                                    </div>
                                </div>
                                <div data-role="collapsible" data-collapsed="true">
                                    <h3>
                                        12:47 pm
                                    </h3>
                                </div>
                            </div>
                        </div>
                        <div data-role="collapsible" data-collapsed="true">
                            <h3>
                                July 6
                            </h3>
                        </div>
                    </div>
                </div>
                <div data-role="collapsible" data-collapsed="true">
                    <h3>
                        August 2012
                    </h3>
                </div>
            </div>
            <a data-role="button" data-transition="slide" href="#page21">
                Graphs
            </a>
        </div>
    </div>

改变标题的功能:

function getLogTime() {
    $('#time1').html('Time');
}

编辑:

如 Joseph Marikle 所说,在周围添加了“”,id=time1修复了未触发的 onclick 事件,但可折叠的图形仍然不显示。

编辑:

Codiqa 生成的 css:

/* Generic icon styles */

/* 26x26 pixels */

.ui-btn-icon-left .ui-btn-inner .ui-icon.ui-iconsize-26, 
.ui-btn-icon-right .ui-btn-inner .ui-icon.ui-iconsize-26 {
margin-top: -13px;
}

.ui-btn-icon-notext .ui-icon { display: block; z-index: 0;}

.ui-btn-icon-top .ui-btn-inner .ui-icon.ui-iconsize-26, .ui-btn-icon-bottom .ui-btn-inner .ui-icon.ui-iconsize-26 { position: absolute; left: 50%;  margin-left: -13px; }
.ui-header .ui-btn-icon-left .ui-icon.ui-iconsize-26,
.ui-footer .ui-btn-icon-left .ui-icon.ui-iconsize-26,
.ui-mini.ui-btn-icon-left .ui-icon.ui-iconsize-26,
.ui-mini .ui-btn-icon-left .ui-icon.ui-iconsize-26 { left: 3px; margin-top: -12px; }

.ui-header .ui-btn-icon-right .ui-icon.ui-iconsize-26,
.ui-footer .ui-btn-icon-right .ui-icon.ui-iconsize-26,
.ui-mini.ui-btn-icon-right .ui-icon.ui-iconsize-26,
.ui-mini .ui-btn-icon-right .ui-icon.ui-iconsize-26 { right: 3px; margin-top: -12px; }

.ui-header .ui-btn-icon-top .ui-icon.ui-iconsize-26,
.ui-footer .ui-btn-icon-top .ui-icon.ui-iconsize-26,
.ui-mini.ui-btn-icon-top .ui-icon.ui-iconsize-26,
.ui-mini .ui-btn-icon-top .ui-icon.ui-iconsize-26 { top: 3px; }

.ui-header .ui-btn-icon-bottom .ui-icon.ui-iconsize-26,
.ui-footer .ui-btn-icon-bottom .ui-icon.ui-iconsize-26,
.ui-mini.ui-btn-icon-bottom .ui-icon.ui-iconsize-26,
.ui-mini .ui-btn-icon-bottom .ui-icon.ui-iconsize-26 { bottom: 3px; }




.ui-icon-ios-pack-color-left-arrow {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-right-arrow {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-up-arrow {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-back {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-forward {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-down-arrow {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
   border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-plus {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
 -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-minus {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-check {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-delete {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-gear {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-refresh {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-grid {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-star {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-info {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-home {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-search {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}

.ui-icon-ios-pack-color-alert {
  width: 26px;
  height: 26px;
  background-color: transparent !important;
  box-shadow: none;
  -moz-box-shadow: none;
  -ms-box-shadow: none;
  -o-box-shadow: none;
  -webkit-box-shadow: none;
  border-radius: 0;
  -moz-border-radius: 0;
  -o-border-radius: 0;
  -ms-border-radius: 0;
}





.ui-icon-ios-pack-color-left-arrow {
  background: url('images/ios-pack-color.png') -260px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-right-arrow {
  background: url('images/ios-pack-color.png') -364px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-up-arrow {
  background: url('images/ios-pack-color.png') -442px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-back {
  background: url('images/ios-pack-color.png') -26px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-forward {
  background: url('images/ios-pack-color.png') -130px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-down-arrow {
  background: url('images/ios-pack-color.png') -104px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-plus {
  background: url('images/ios-pack-color.png') -312px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-minus {
  background: url('images/ios-pack-color.png') -286px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-check {
  background: url('images/ios-pack-color.png') -52px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-delete {
  background: url('images/ios-pack-color.png') -78px 50% no-repeat transparent     !important;
}

.ui-icon-ios-pack-color-gear {
  background: url('images/ios-pack-color.png') -156px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-refresh {
  background: url('images/ios-pack-color.png') -338px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-grid {
  background: url('images/ios-pack-color.png') -182px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-star {
  background: url('images/ios-pack-color.png') -416px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-info {
  background: url('images/ios-pack-color.png') -234px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-home {
  background: url('images/ios-pack-color.png') -208px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-search {
  background: url('images/ios-pack-color.png') -390px 50% no-repeat transparent !important;
}

.ui-icon-ios-pack-color-alert {
  background: url('images/ios-pack-color.png') -0px 50% no-repeat transparent !important;
}


@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
       only screen and (min--moz-device-pixel-ratio: 1.5),
       only screen and (min-resolution: 240dpi) {

  .ui-icon-ios-pack-color-left-arrow,.ui-icon-ios-pack-color-right-arrow,.ui-icon-ios-pack-color-up-arrow,.ui-icon-ios-pack-color-back,.ui-icon-ios-pack-color-forward,.ui-icon-ios-pack-color-down-arrow,.ui-icon-ios-pack-color-plus,.ui-icon-ios-pack-color-minus,.ui-icon-ios-pack-color-check,.ui-icon-ios-pack-color-delete,.ui-icon-ios-pack-color-gear,.ui-icon-ios-pack-color-refresh,.ui-icon-ios-pack-color-grid,.ui-icon-ios-pack-color-star,.ui-icon-ios-pack-color-info,.ui-icon-ios-pack-color-home,.ui-icon-ios-pack-color-search,.ui-icon-ios-pack-color-alert {
    background-image: url('images/ios-pack-color@2x.png');
    -moz-background-size: 468px 26px;
    -o-background-size: 468px 26px;
    -webkit-background-size: 468px 26px;
    background-size: 468px 26px;
  }

}


.text-align-center {
  text-align: center;
}
.text-align-right {
  text-align: right;
}

/** CSS for non-standard jQuery Mobile styles or Codiqa components **/
.split-wrapper {
  width: 100%;
  min-height: 200px;
  clear: both;
}
@media all and (min-width: 650px) {
    .content-secondary {
        text-align: left;
        float: left;
        width: 45%;
        background: none;
        padding: 1.5em 6% 3em 0;
        margin: 0;
    }
    .content-secondary {
    background: none;
    border-top: none;
    }
    .content-primary {
        width: 45%;
        float: right;
        margin-right: 1%;
        padding-right: 1%;
    }
    .content-primary ul:first-child {
        margin-top: 0;
    }
  .content-secondary ul.ui-listview, .content-secondary ul.ui-listview-inset {
    margin: 0;
  }
  .content-secondary ul.ui-listview .ui-li-divider, .content-secondary ul.ui-listview         .ui-li {
    border-radius: 0px;
  }
  .content-secondary ul.ui-listview .ui-li {
    border-left: 0;
    border-right: 0;
  }
    .content-secondary h2 {
        position: absolute;
        left: -9999px;
    }
    .content-secondary .ui-li-divider {
        padding-top: 1em;
        padding-bottom: 1em;
    }
    .content-secondary {
        margin: 0;
        padding: 0;
    }

}
@media all and (min-width: 750px){
    .content-secondary {
        width: 34%;
    }
    .content-primary {
        width: 60%;
        padding-right: 1%;
    }   
  .content-secondary ul.ui-listview-inset {
}

@media all and (min-width: 1200px){
    .content-secondary {
        width: 30%;
        padding-right:6%;
        margin: 0px 0 20px 5%;
    }
    .content-secondary ul {
    margin: 0;
  }
    .content-secondary {
        margin: 0;
        padding: 0;
    }
    .content-primary {
        width: 50%;
        margin-right: 5%;
        padding-right: 3%;
    }
    .content-primary {
        width: 60%;
    }
}

该 html 文件还使用<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.1.0/jquery.mobile-1.1.0.min.css" />

4

1 回答 1

1

我想我已经弄清楚是什么导致了你的问题。我上面链接的演示确实重现了问题

点击
2012 年 7 月->7 月 5 日->//有问题的标题->日志 1

您遇到的问题是由您使用的移动图书馆引起的。使用此库时,它会更改 HTML,将子元素添加到现有元素。因此,当您更改元素的 HTML 时,它会极大地改变样式。您需要做的是找到放置文本的位置。根据我的调查,似乎可以在元素中找到文本,其类为ui-btn-text. 从那里它就像更改代码中的选择器一样简单(我也使用text了代替html):

function getLogTime() {
    $('#time1 .ui-btn-text').text('Time');
}

您可以在我的演示)的工作版本中看到它

如果您有任何问题,请发表评论。

于 2012-08-01T20:32:00.270 回答