hashchange

架构设计:前后端分离之Web前端架构设计

蹲街弑〆低调 提交于 2019-12-21 04:29:49
  在前面的文章里我谈到了前后端分离的一些看法,这个看法是从宏观的角度来思考的,没有具体的落地实现,今天我将延续上篇文章的主题,从纯前端的架构设计角度谈谈前后端分离的一种具体实现方案,该方案和我原来设想有了很大的变化,但是核心思想没变,就是控制层是属于Web前端的。   在以前文章里我说道前后端分离的核心在于把mvc的控制层归为前端的一部分,原方案的构想在实际的生产开发里很难做到,我觉得核心还是控制层和视图层的技术异构性,这样后果使得系统改造牵涉面太大,导致在项目团队里,沟通、协调以及管理成本相对较高,随着前端技术的发展,前端开发的工程量是越来越大,难度也是越来越高,因此前端工程的项目化,工程化和独立性越来越被人重视了,所以出现了大量的javascript MVC的富应用。如果javascript也能做到MVC模式,那么前端框架就可以抛弃异构语言的控制层,做到真正的独立。   要把传统的MVC的C层从前端剥离掉,我们首先要理解下MVC的C层即控制层到底做了什么样的事情,控制层的作用是模型层和视图层沟通的纽带,模型层进一步具体点就是数据层,视图层具体点就是数据展示给用户的方式,下面我们看看java的Web应用里,控制层和视图层是如何耦合的呢?做过java的web开发的人第一个反应就是页面里回嵌入大量java代码或者使用jsp的标签或者使用velocity

The best Ajax History and Bookmark plugin currently available [closed]

纵然是瞬间 提交于 2019-12-20 03:44:07
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . It seems that each Ajax History and Bookmark plugin has some minor bugs, ranging from Really Simple History http://code.google.com/p

onhashchange with IE 9

為{幸葍}努か 提交于 2019-12-19 09:26:48
问题 I have the following code $(document).ready(function() { if ("onhashchange" in window) { alert("The browser supports the hashchange event!"); } function test(){ alert("hash has changed = " + window.location.hash) } window.onhashchange =test; } I click a link that changes the hash and in all other browsers I get the alert in test However in IE I get the first alert saying it supports onhashchange but then when the hash changes nothing happens. Any ideas? 回答1: There's an example on the MSDN doc

What's the best library to do a URL hash/history in JQuery? [closed]

谁说我不能喝 提交于 2019-12-17 10:37:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I've been looking around JQuery libraries for the URL hash, but found none that were good. There is the "history plugin", but we all know it's buggy and isn't flexible. I am loading my pages inside a div. I'll need a way to do back/forward along with the url hashing. mydomain.com/#home mydomain.com/#aboutus

How to keep the browser history in sync when using Ajax?

醉酒当歌 提交于 2019-12-17 06:45:27
问题 I'm writing a simple photo album app using ASP.NET Ajax. The app uses async Ajax calls to pre-load the next photo in the album, without changing the URL in the browser. The problem is that when the user clicks the back button in the browser, the app doesn't go back to the previous photo, instead, it navigates to the home page of the application. Is there a way to trick the browser into adding each Ajax call to the browsing history? 回答1: Update: There is now the HTML5 History API (pushState,

scollTo + hashchange: Weird back/forward behavior

戏子无情 提交于 2019-12-13 02:27:55
问题 I'm trying to use Ariel Fiesler's scrollTo plugin in conjunction with Ben Alman's hashchange plugin. Basically I'm scrolling to different DIVs on my page, and trying to use hashchange for back/forward button functionality. It sort of works, but it's inconsistent. On every other back or forward, it scrolls. But on the others it just jumps to the scroll position. So you get something like: 1. Jump, 2. Scroll, 3. Jump, 4. Scroll and so on. Here's a link to the live site: http://www.6by7.net/ And

jQuery: Fire event in other tab/window

百般思念 提交于 2019-12-12 01:45:26
问题 I have two browser windows A and B open side by side. When someone clicks a button in window A I want to run a function in window B . I’m currently using the hashchange event in window B and the window.open(myurl,myurl) in window A to tell the other window to start running the function, but this doesn’t work very well when the url changes. Is there another solution in javascript to init events outside the current window? 回答1: One way I can think of is to provoke a localStorage change that the

Toggling between 2 bookmarks (or see a page, and load another page from bookmark) won't work with jQuery History plugin

妖精的绣舞 提交于 2019-12-11 18:38:12
问题 Anyone knows how to fix this jQuery History plugin? (for ajax history and bookmark) In http://github.com/tkyk/jquery-history-plugin/issues#issue/5 This is the details: My app using IE 8's IE 7 Compatibility Mode as well as http://www.serpere.info/jquery-history-plugin/samples/ajax, which is using IE 8's default mode, seem to have this problem: Create 2 bookmarks http://www.serpere.info/jquery-history-plugin/samples/ajax/#1 http://www.serpere.info/jquery-history-plugin/samples/ajax/#2 now

Jquery + up to date hash change listener?

筅森魡賤 提交于 2019-12-11 15:35:46
问题 I'm using http://benalman.com/projects/jquery-hashchange-plugin/ to listen for hash changes in my project, but his plugin is outdated and does not work with newer versions of browsers such as Firefox 9 and IE9. Searched on Google and here but could not find any other plugin. Or is it enough to just use this code to target most of the browsers? $(window).bind('hashchange', function() { //code }); EDIT: Seems like there was a problem regarding console.log() on these browsers and had nothing to

Hashchange not firing when user clicks on same link

断了今生、忘了曾经 提交于 2019-12-11 11:07:27
问题 I'm creating an HTML and Javascript client for running in browser which talks to REST API. I'm using RouteMap to set my URLs. So I've kept a convention something like this http://mysite.com/#/{ResourceName}/[edit|view|list]/[Id]/ I've set just one route and I'm grabbing these parameters in the function bounded to hashchange. Most of the things work fine. Just two issues and I'm stuck because of them. If the user clicks on the same link twice, hashchange event doesn't fire. Yes, hash has not