javascript-framework

panel drag and drop is not working in extjs 4.1

微笑、不失礼 提交于 2019-12-01 09:25:55
问题 This code is working in Extjs 4.0.2a but when converted to 4.1 it no longer works and gives an error Uncaught TypeError: Cannot call method 'query' of undefined Ext.onReady(function() { var panel = new Ext.Panel({ renderTo: divtag, draggable: { insertProxy: false, onDrag: function(e) { var el = this.proxy.getEl(); this.x = el.getLeft(true); this.y = el.getTop(true); }, endDrag: function(e) { this.panel.setPosition(this.x, this.y); } }, title: 'Panel', width: 200, height: 100, x: 20, y: 20 });

PMT in Javascript

南楼画角 提交于 2019-12-01 06:21:00
I am trying to code the equivalent to the EXCEL PMT function. in Java Script, the formula looks like this: function PMT (ir, np, pv, fv ) { /* ir - interest rate per month np - number of periods (months) pv - present value fv - future value (residual value) */ pmt = ( ir * ( pv * Math.pow ( (ir+1), np ) + fv ) ) / ( ( ir + 1 ) * ( Math.pow ( (ir+1), np) -1 ) ); return pmt; } This is great for PMT calcs where Type =1 (i.e. payments occur at the start of the period) However, I'm trying to code for a Type 0 scenario (i.e. payments occur at the end of the period)). Any math wizards out there who

PMT in Javascript

你离开我真会死。 提交于 2019-12-01 06:03:41
问题 I am trying to code the equivalent to the EXCEL PMT function. in JavaScript, the formula looks like this: function PMT (ir, np, pv, fv ) { /* ir - interest rate per month np - number of periods (months) pv - present value fv - future value (residual value) */ pmt = ( ir * ( pv * Math.pow ( (ir+1), np ) + fv ) ) / ( ( ir + 1 ) * ( Math.pow ( (ir+1), np) -1 ) ); return pmt; } This is great for PMT calcs where Type =1 (i.e. payments occur at the start of the period) However, I'm trying to code

How to find unique records from two different array in jquery or javascript?

无人久伴 提交于 2019-11-30 20:38:29
I want to get unique values from two different arrays. Two arrays are as below in JavaScript: <script> var a=new Array; var b=new Array; a={'a','b','c','d','e'} b={'a','d','e','c'} </script> I want output like: new array => {'a','c','d','e'} How can I find unique records from both arrays using JavaScript prototype function or jQuery function? I don't know if you have the terms correct. Unique values to me would be members which appear only once in either array. It seems you want members that are present in both arrays (common values, or intersection ), based on your example. You can use jQuery

AngularJS use a function in a controller to return data from a service to be used in ng-repeat

痞子三分冷 提交于 2019-11-30 19:31:29
I am trying to use a function in a controller to return data so that I can re-use the function across the app to call the data as well as refresh it occasionally. My code appears correct, but in practice, crashes the browser on each load. I am able to get it to work by using an E directive and then placing the element in the partial, but that doesn't accomplish what I need. Ultimately, I would like to do something like this: <div ng-repeat="user in getListUsers()">{{ user.somedata }}</div> I have tried various things to get it to work in testing, including putting the $http in the controller,

jQuery equivalent for window.document.write

蓝咒 提交于 2019-11-30 18:40:23
Does anyone know the jQuery equivalent for window.document.write('') in javascript? Thanks This will add the string "hello" right before the body closing tag. Not exactly the behavior of write , but you can do this to any element to get the content to appear where you want it. $(document.body).append('hello'); Also available are prepend(content) and replaceWith(content) for all your insertion needs! First, jQuery is JavaScript, it is just a library of functions to make coding easier. Second, you should avoid the use of document.write . You should use jQuery to append the text to the DOM

How can I keep jointjs cells from overflowing the paper?

拜拜、爱过 提交于 2019-11-30 17:50:54
I'm using jointjs to make diagrams which will be user-editable. The user may drag them around and relocate each cell. However, when a cell is dragged to the edge, it overflows and becomes cut off. I want to prevent this from happening, instead the cell to stop before it gets to the edge of the paper and not be allowed to cross the edge, thus always staying completely within the paper. The behavior can be seen in jointjs' very own demos here: http://www.jointjs.com/tutorial/ports Try dragging the cell to the edge and you'll see that it eventually becomes hidden as it crosses the edge of the

How to set up JavaScript namespace and classes properly?

China☆狼群 提交于 2019-11-30 10:13:45
问题 It seems there are so many ways to set up a JavaScript application so it is confusing as to which one is correct or best. Are there any difference to the below techniques or a better way of doing this? MyNamespace.MyClass = { someProperty: 5, anotherProperty: false, init: function () { //do initialization }, someFunction: function () { //do something } }; $(function () { MyNamespace.MyClass.init(); }); Another way: MyNamespace.MyClass = (function () { var someProperty = 5; var anotherProperty

Google AngularJS Framework - Worth the risk?

≯℡__Kan透↙ 提交于 2019-11-30 10:10:06
问题 I have been asked to build a small web application for one of our clients and think it might be a good opportunity to try out a different framework for building web applications. Most of the applications we build are based on asp.net web forms and we have no yet done anything in an MVC architecture but I am eager to start building web applications in a more structured manner with the right tools. I have been researching things like asp.net MVC and the likes which look quite good but I am

Is there anyway to detect OS language using javascript?

↘锁芯ラ 提交于 2019-11-30 08:32:15
问题 I need to detect OS language using javascript so I can view my page depending on the language. I know that we can detect the browser language but that is not enough for me. I need Operation System language Thanks in advance 回答1: There is no cross-browser way to do this. Internet Explorer supports the following: navigator.browserLanguage : browser language navigator.systemLanguage : Windows system language navigator.userLanguage : Windows user-specific language But there is no way to access