Javascript: Module Pattern vs Constructor/Prototype pattern?

I would like to know if the module pattern or Constructor/protoType pattern is more applicable to my work. Basically I am using unobtrusive javascript -- the HTML document has a reference to the .js file. My understanding of the module pattern: call an INIT method (which is basically a public method i can create and return using the module pattern) In the INIT method, assign all click eve

Javascript:模块模式vs构造函数/原型模式?

我想知道模块模式或Constructor / protoType模式是否更适用于我的工作。 基本上我使用不显眼的JavaScript - HTML文档有一个对.js文件的引用。 我对模块模式的理解: 调用一个INIT方法(这基本上是一个公共方法,我可以使用模块模式创建和返回) 在INIT方法中,分配所有点击事件等。 这听起来像是我的情况的完美模式,因为我不需要创建对象和继承层次结构等。 我对构造函数/原型模式的理解: 用于创建对象 为了

Simple javascript inheritance using $.extend and module pattern

I have wondered for a couple years now what people think of doing inheritance with a module-pattern-esque constructor pattern and WITHOUT normal prototypal inheritance. Why do programmers not use a module pattern for non-singleton js classes? For me the advantages are: Very clear public and private scope (easy to understand the code and the api) No needing to track the 'this' pointe

简单的JavaScript继承使用$ .extend和模块模式

我想了好几年现在人们想到用模块式模式构造器模式继承并且没有正常的原型继承。 为什么程序员不为非单例式js类使用模块模式? 对我来说,优点是: 非常明确的公共和私人范围(易于理解代码和api) 不需要在回调中通过$ .proxy(fn,this)跟踪'this'指针 没有更多的var = this,等等事件处理程序等等。每当我看到一个'this'时,我知道它是传递给回调的上下文,它不是我正在跟踪的知道我的对象实例的东西

AngularJS: Understanding design pattern

In the context of this post by Igor Minar, lead of AngularJS: MVC vs MVVM vs MVP . What a controversial topic that many developers can spend hours and hours debating and arguing about. For several years AngularJS was closer to MVC (or rather one of its client-side variants), but over time and thanks to many refactorings and api improvements, it's now closer to MVVM – the $scope object co

AngularJS:了解设计模式

AngularJS负责人Igor Minar在本文的背景中提到: MVC vs MVVM vs MVP 。 许多开发人员可能会花费数小时甚至数小时进行辩论和争论,这是多么有争议的话题。 多年来,AngularJS更接近于MVC(或者更确切地说是它的一个客户端变体),但随着时间的推移以及许多重构和api改进,现在更接近于MVVM - $ scope对象可以被视为ViewModel由我们称之为控制器的功能装饰。 能够将框架分类并将其放入其中一个MV *桶中具有一些优势。 它

iPad Javascript/jQuery touchstart issue

I have a page on iPad and am facing some issues implementing an equivalent of mouseout behavior. So I have: On my page, there is a checkbox on click (or rather touch), I want to show an errorMsg On click/touch on anything other than the errorMsg, I want to hide the errorMsg Below is the code I have written; $(document).bind("touchstart",function(e){ if(e.target.id != "checkbox_e

iPad Javascript / jQuery touchstart问题

我在iPad上有一个页面,并且遇到了一些实现相应的鼠标移动行为的问题。 所以我有: 在我的页面上,点击(或者更确切地说,触摸)时有一个复选框,我想显示errorMsg 点击/触摸errorMsg以外的任何东西,我想隐藏errorMsg 以下是我写的代码; $(document).bind("touchstart",function(e){ if(e.target.id != "checkbox_err") $("span#checkbox_err").fadeOut("slow"); }); } $("input:checkbox").bi

jQuery Ajax Submit Post not getting success message back

The code works on until I reach the action.php where I post my input. The issue is that the Post never reaches the action.php and all I get is a blank variable. using: https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js <script type="text/javascript"> function submitdata() { var name=document.getElementById('name'); $.ajax({ type: 'post', url: 'action.php', data:

jQuery Ajax提交帖子没有收到成功的消息

代码一直工作,直到我到达action.php我发布我的输入。 问题在于帖子从未到达action.php,我得到的只是一个空白变量。 使用:https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js <script type="text/javascript"> function submitdata() { var name=document.getElementById('name'); $.ajax({ type: 'post', url: 'action.php', data: { 'name':name }, cache:false, success: fun

Error using jQuery UI Selectmenu plugin in IE

The jQuery UI Selectmenu plugin, demoed here: http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html I am having a couple of problems with this plugin. I'll focus on just one that only happens in IE. I have html: <label for="SearchState"></label> <select style="width: 160px" name="SearchState" id="SearchState"> <option>CT</option> <

在IE中使用jQuery UI Selectmenu插件时出错

这里演示了jQuery UI Selectmenu插件:http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html 我有这个插件的一些问题。 我将专注于仅在IE中发生的一个。 我有html: <label for="SearchState"></label> <select style="width: 160px" name="SearchState" id="SearchState"> <option>CT</option> <option>MA</option> <option>NH</option

CSS hover effect on ajax content and mobile devices

I've build a quiz. Each question has 2 answers. When the visitor answers a question, the next one is loaded using Ajax. Before the questions are loaded the visitor has to click a start button first, so the HTML for the questions isn't included in the initial page load. The problem is when a question is anwsered, the hover effect from the previous question is still active when the nex

Ajax内容和移动设备上的CSS悬停效果

我已经建立了一个测验。 每个问题有2个答案。 当访问者回答问题时,下一个使用Ajax加载。 在加载问题之前,访问者必须首先点击一个开始按钮,因此问题的HTML不包含在初始页面加载中。 问题出在问题出现时,上一个问题的悬停效果在下一个问题加载时仍然有效。 例如:我用“B”填充问题1>加载问题2>悬停效果在问题2的按钮B上激活 我已经加入了一张图片来使这个更清晰。 我只在移动设备(iPhone,iPad,...)上使用

Improving the Bookmarklet Experience

So I have a site specific bookmarklet that create a page with a toolbar (using localstorage to set/get variables) and then creates an iframe for a destination site, say www.example.com . [Idea heavily borrowed from the wonderful RWD Bookmarklet (http://responsive.victorcoulon.fr/) ]. It works great, but I wanted to provide that a clickable link to that bookmarklet (because it is a pain to add a

改进书签体验

因此,我有一个网站特定的小书签,它使用工具栏创建一个页面(使用localstorage设置/获取变量),然后为目标网站创建一个iframe,例如www.example.com 。 [想法大量借鉴了美妙的RWD Bookmarklet(http://responsive.victorcoulon.fr/)]。 它很好用,但我想提供一个可点击的书签链接(因为在Ipad中添加小书签是一种痛苦),但不幸的是,由于链接不驻留在www.example.com ,导致显而易见的XSS跨站点问题www.example.com 。 为

Mobile Safari crash first time page is loaded

I've built a Javascript-heavy web app and recently tweaked it to work on iPad (it needed tweaks because it allows drawing by moving the mouse around, and onmousedown/onmousemove would not get triggered until finger release). Now, with the tweaks, the app runs fine on Mobile Safari. I'm seeing a problem, however, where the first time I try to load the app on the iPad, it often crashes M

移动Safari首次崩溃的第一次页面加载

我已经构建了一个Javascript重载的Web应用程序,最近调整了它在iPad上的工作(它需要调整,因为它允许通过移动鼠标来绘图,并且onmousedown / onmousemove不会被触发,直到手指释放)。 现在,通过调整,该应用在移动Safari上运行良好。 但是,我看到一个问题,那就是我第一次尝试在iPad上加载应用程序时,经常会使Mobile Safari崩溃。 但是,重新打开浏览器并刷新页面可以完美地加载应用程序,并且完全可用。 在做了一些研

Multiple Dropdowns causes issue on FIREFOX if options are disabled

Suppose we have 2 dropdowns on the page <div>1st dropdown</div> <select id="1" class="DROPDOWN"> <option>1</option> <option>2</option> </select> <div>2nd dropdown</div> <select id="2" class="DROPDOWN"> <option>3</option> <option>4</option> </select> &l

如果禁用选项,则多个下拉菜单会导致FIREFOX出现问题

假设我们在页面上有2个下拉菜单 <div>1st dropdown</div> <select id="1" class="DROPDOWN"> <option>1</option> <option>2</option> </select> <div>2nd dropdown</div> <select id="2" class="DROPDOWN"> <option>3</option> <option>4</option> </select> <div id="