complete 相关问题


使用部分进行主动拆解/重新渲染不会重新渲染部分

这是小提琴(对警报感到抱歉)http://jsfiddle.net/PCcqJ/92/ var ractive = new Ractive({ 模板:'#templateOne', 部分:{ aPartial:'哦,看,partia... 这是小提琴(抱歉有警报)http://jsfiddle.net/PCcqJ/92/ var ractive = new Ractive({ template: '#templateOne', partials: { aPartial: '<div>Oh look, the partial is rendered!</div>' } }); function cb() { alert('but now we unrender'); ractive.once('complete', function() { alert('we rendered again, and now you can\'t see the partial content'); }); ractive.render('container'); } ractive.render('container'); ractive.once('complete', function() { alert('so we render the first time, and you can see the partial'); ractive.unrender().then(cb); }); 此处的部分不会重新渲染。为什么是这样?部分仍在部分对象中,并且它们尚未渲染,那么什么会阻止它们再次渲染? 这个小提琴会渲染、取消渲染,然后重新渲染,每次发生其中一种情况时都会向您发出警报。 我做了一个工作jsfiddle:https://jsfiddle.net/43gLqbku/1/ <div id='container'></div> <script id="templateOne" type="x-template"> {{>aPartial}} </script> var ractive = new Ractive({ el:"#container", template: '#templateOne', partials: { aPartial: '<div>Oh look, the partial is rendered!</div>' } }); function cb() { alert('but now we unrender'); ractive.once('complete', function() { alert('we rendered again, and now you can\'t see the partial content'); }); ractive.render('container'); } //ractive.partials.part = '<div>this is a partial</div>'; ractive.once('complete', function() { alert('so we render the first time, and you can see the partial'); ractive.unrender().then(cb); }); 在调用render之前需要调用ractive.once('completed') 你不需要 ractive.render("container");在活动代码下,因为它在第一次运行时自动呈现 在你的jsfiddle中你导入的ractive不起作用 你没有在 jsFiddle 活动代码中包含 el:"#container"


引导进度条没有进度

引导进度条在我的 MVC 索引视图上不起作用。 我已经用 Chrome 和 Internet Explorer 尝试过了。 @{ ViewBag.Title = "首页"; } 引导进度条在我的 MVC 索引视图上不起作用。 我已经用 Chrome 和 Internet Explorer 尝试过了。 @{ ViewBag.Title = "Home Page"; } <div class="jumbotron"> <h1>ASP.NET</h1> <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p> <p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more &raquo;</a></p> </div> <div class="row"> <div class="col-md-4"> <h2>Getting started</h2> <div class="progress-bar progress-striped "></div> </div> </div> 本次聚会迟到了,但在我使用的 Bootstrap 版本(v3.1.1)中,该类是“progress-striped”(不是像文档所说的“progress-bar-striped”),并且它和“active” ' 类必须应用于外部 div: <div class="progress progress-striped active"> <div class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">Some text</div> </div> 查看 CSS,选择器“progress-bar”已更改为“bar”: ./bootstrap.css: .progress { ... } .progress .bar { ... } 因此,将您的代码更改为 <div class="progress"> <div class="bar"> </div> </div> 然后就可以了。 不确定这种疯狂的原因是什么,似乎引导文档还没有更新。 <div class="progress"> <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%"></div> </div> 这样进度动画就可以工作了。 <div class="progress"> <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%;"> <span class="sr-only">60% Complete</span> </div> </div> 上面是 bootstrap v3.1.1 的代码,看起来你的进度条 div 缺少一些元素? 如果您使用 Bootstrap v4 并且需要动画,则需要使用 progress-bar-animated 而不是 active。


在 Rails 5 中单击浏览器上的后退按钮时,带有 Select2 的表单会重复

_header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> _header.html.erb(用于表单部分) <%= form_for home_path, class: 'home', role: 'search', method: :get do |f| %> <div class="form-group" style="display:inline;"> <div class="input-group input-group-md"> <%= text_field_tag :q, params[:q], placeholder: ... ,class: 'form-control hideOverflow', type: "search" %> <%= select_tag "category", options_from_collection_for_select(...),include_blank: true, class: 'form-control hideOverflow', type: "search" %> <%if logged_in? %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', type: "search" %> <% else %> <%= select_tag "location", options_for_select([...], ...),class: 'form-control hideOverflow', include_blank: true, type: "search" %> <% end %> <span class="input-group-addon"><%= submit_tag "Search", class: "btn-transparent"%></span> </div> </div> <% end %> JS代码 <script> $( document ).on('turbolinks:load', function() { $('select#category').select2({ width: '60%', dropdownAutoWidth : true, placeholder: "Choose a category", maximumSelectionLength: 3 }); $('select#location').select2({ width: '40%', dropdownAutoWidth : true, minimumResultsForSearch: Infinity }); }); </script> 故障或渲染问题(单击链接查看图像) 有人可以帮我解决为什么吗?另外,我的搜索表单位于标题部分文件的导航栏中。 如果我去掉脚本中的 $(...).select ,一切都会正常...我认为 select.js 有问题 在此回复: https://stackoverflow.com/a/41915129/5758027 我在自己的代码中使用了这个解决方案: $(document).on('turbolinks:before-cache', function() { // this approach corrects the select 2 to be duplicated when clicking the back button. $('.select-select2').select2('destroy'); $('.select-search-select2').select2('destroy'); } ); 和观察者: $(document).ready( ready ); //... once document ready $(document).ajaxComplete( ready ); //... once ajax is complete $(document).on('turbolinks:load', ready ); //... once a link is clicked function ready() { $(".select-search-select2").select2({ theme: "bootstrap", language: 'es', allowClear: true }); $(".select-select2").select2({ theme: "bootstrap", language: 'es', minimumResultsForSearch: Infinity, allowClear: true }); }; 总是清除缓存不是会让使用 Turbolink 变得毫无意义吗? 不如这样? $(document).on('turbolinks:before-cache', function(e) { return $('.form-control.select2').each(function() { return $(this).select2('destroy'); }); }); 我无法解决这个渲染问题(仍在等待正确的答案!),但如果有人像我一样遇到类似的问题,请尝试跳出框框思考。这是我的技巧:我在应用程序中添加了一个后退按钮。 获取完整的url路径 # get the previous url def save_previous_page session[:return_to] = request.fullpath end 仅当页面不是主页或搜索页面时才显示后退按钮 <% if session[:return_to] != request.fullpath%> <%= link_to session.delete(:return_to) || request.fullpath, class: 'back-button' do%> <i class="fa fa-arrow-circle-left" aria-hidden="true"></i> <%end%> <% end %> 同时,我仍在等待并尝试解决渲染问题... 解决了问题 只需将此代码添加到您的 .js 文件中 Turbolinks.clearCache(); 这很可能是一些资源不一致,您应该检查您的 app\views\layouts 文件夹中是否有重复声明 wither jQuery、jQuery UJS 或 Turbolinks 的文件。检查页面的所有 <script> 标签,以及是否在 layout 文件夹和内部视图中声明相同的脚本。如果情况并非如此,请检查是否有 render、yield 或 build 呼叫 简单的解决方案,不要在您不希望它运行的东西上运行 select2 构建器。 $("select#category:not(.select2-container):not(.select2-hidden-accessible)").select2(); Rails 7 更新 这里的很多东西在 Rails 7 中都不起作用,尤其是 turbolinks:before-cache 事件。您正在寻找的新事件是 turbo:before-cache 和 turbo:load,所以它看起来像这样: $(document).on("turbo:before-cache", function() { $("#select_id").select2('destroy'); }); $(document).on('turbo:load', function() { $('#select_id').select2(); });


© www.soinside.com 2019 - 2024. All rights reserved.