yui

Javascript alphabetical grouping

大兔子大兔子 提交于 2019-12-11 05:02:02
问题 I have a json array of objects that look like this: {id:'the id', name:'the name'}; and I need to loop over the array and group each object alphabetically by it's name attribute. Is there a way to do this without using a switch / if statement with every letter in it? What I don't want to do is something like this: if(data[i].name..slice(0, 1) == 'a') { ... } It's a large array, with almost a 1,000 objects in it. My goal is eventually append them to a dive so it looks something like this: 4 4

How to disable YUI2 silent failing?

淺唱寂寞╮ 提交于 2019-12-11 04:44:32
问题 YUI 2 often fails silently, e.g. when you expect the this to be another object and call an unexisting method on it. Is there any way make errors "visible"? 回答1: If your code is running in a YUI event handler, then YUI catches the exception and you won't see it in the debugger. To see these exceptions, you either need to catch the exception yourself and output something to the debug console or turn on the right logging in YUI so it outputs the exceptions. I've looked for the right logging

How to parse NULL value returned using YUI datasource

别来无恙 提交于 2019-12-11 03:43:12
问题 I am using YUI datatable and datasource to render data in one of my projects. The data returned happens to be NULL and YUI datasource is unable to parse it. Below is the declaration code of datasource and datatable. For readability sake, I am seperating each of the declarations. Column Descriptions declaration var columnDescription = [ {key:'Requirements'}, {key:'abc'}, {key:'xyz'} ]; This columnDescription is set in the function below. DataSource Declaration var dataSrcSample = new YAHOO

Pass data from server-side to YUI 3 JavaScript application

允我心安 提交于 2019-12-11 02:03:27
问题 I am working on rewriting my application from YUI 2 to YUI 3. Sometimes I need some data from database in my JavaScript environment. Firs option is to assign some global variables in JavaScript, but global vars is not good, so I did following in YUI 2: app.js YAHOO.namespace('MyApp'); YAHOO.MyApp = function() { var currencyRates; var userInfo; /* here a lot of code with event listeners and dom manipulations which uses currencyRates and userInfo variables */ return { initCurrencyRates:

Client-side filter of YUI Datatable with select list?

故事扮演 提交于 2019-12-10 16:32:01
问题 Can I filter the rows of a static dataset using multiple drop-down menus and a paginated YUI datatable ? http://www.mappingbahia.org/project/iguape_dataset.html 回答1: Each YAHOO.widget component such as YUI DataTable uses a YUI DataSource component which provides data needed To populate each rendered YAHOO.widget component . Bellow you can see how it works Notice each YAHOO.widget component internally makes a call To The underlying YUI datasource Through sendRequest method (See step 1). Now

How to delay the onLoad event which gets fired on the browser?

时间秒杀一切 提交于 2019-12-10 14:31:44
问题 I am trying to delay the onLoad event that gets fired. Is there a way to delay this event strictly using javascript on the client side ? 回答1: If you put a script tag at the end of the body like: <body> ... <script> setTimeout(function(){ //deferred onload }, 2000); </script> </body> The function will be executed after 2 sec in this case As said in my comment below: you shouldn't rely on a delay. But use a callback on a certain event. If impossible, may be a better bad solution, is to use

yui input group validation

断了今生、忘了曾经 提交于 2019-12-10 10:56:51
问题 I've been working on the validation of a form using AlloyUI/Yui, but I have the following problem: I have 3 input fields that are for the date of birth, they are all required so when I click the submit button I get 3 "this field is required" messages that are breaking my layout. Is there a way to make the script show only one message instead of 3? I have a jsfiddle (http://jsfiddle.net/0yak4z07/9/) showing the issue. The code is pasted below too: YUI().use('aui-form-validator', function (Y) {

Aligning the baseline of a YUI button with the baseline of the text next to it

ぐ巨炮叔叔 提交于 2019-12-09 23:38:02
问题 I'd like to display a YUI button next to some text, but the baseline of the YUI button text does not line up with the baseline of the text next to it. The font family and size is identical for both the button text and the text next to it. If I use a plain HTML button the text baselines correctly line up. Here's a live example of the problem. How can I get the text baselines to line up? 回答1: Enclose the adjacent text in a span tag with the following styles: <span style="vertical-align: middle;

YUI Editor (RTE): Insert HTML element and place cursor inside

↘锁芯ラ 提交于 2019-12-09 19:26:01
问题 I have a problem. I've been trying to tackle it for a while now and I'm ready to explode. Here's my requirement: I have an external toolbar (not part of YUI) above the editor that I want to use to insert HTML tags. The user should be able to click a link on the toolbar after which a few things may happen: If there's any selected text, this text gets wrapped into an HTML tag If there's no selected text, an empty HTML tag is inserted in the editor Regardless of the scenario, cursor MUST be

Order of loading external CSS and JavaScript files

半城伤御伤魂 提交于 2019-12-09 05:37:48
问题 I have a third party application that loads many css and javascript files, and I now want to optimize this by concatinating all the javascripts into one file, compressed by the yuicompressor, but ... when we have a mix like: <script type="text/javascript" src="script1.js"></script> <script type="text/javascript" src="script2.js"></script> <link rel="stylesheet" href="style1.css" type="text/css" /> <script type="text/javascript" src="script3.js"></script> <script type="text/javascript" src=