I was wanting to display a slideshow if images in my blog posts for battle reports but kept hitting on the problem with most of them that you couldn’t have more than one on the page at the same time so I thought, “How difficult could it be?”. not too bad as it turned out.
I hit one snag when I was checking for the “currentslide” but setting the slide to “.currentslide” so it would only loop to one image and then another issue that seemed to cause the whole thing to just thunder through the images very quickly. In the end with some help from the wonderful people on stackoverflow.com, I got the problem solved.
The code is very simple and not a jquery plugin as some have suggested I write, but for a first version it works.
I had a problem, in the page I was working on, I have several sections, only one gets displayed at a time and they all have the same field at the top of each section called “Label”, when the user moved through the sections, if they have provided a Label it should automatically be populated in the new section. jQuery to the rescue with .filter(). Which allowed me to find only the label elements where the value was not empty and then easily copy it to a new section.
Not rocket science but useful.
This is why I love StackOverflow. I was designing an app that has a list of actions that a user can perform and I was thinking from a usability standpoint if the user cannot perform the type of action it should disappear from the list, and I planned to do this with CSS. Ahh the Best Laid Plans of Mice and Men. While the ides of setting the display property of the option to none seemed at the outset to be the way to go, the problem with any solution like this is it needed to be cross-browser compliant. My initial idea having failed to achieve this I went searching on StackOverflow and found as you would expect someone else had already asked this same question.
And you can use it in the following way
Very useful indeed.
I was just working on an ajax component to communicate with a Spring.Net Webservice component and the operation returns an object in the event of an error, and all I really required was one of the properties of the object, i.e. the error message.
While I could have spent ages searching trying to find the names of all the properties of the object returned so I could work out the name of the property I wanted, I instead went to my old faithful.
Yes, eval(), I have heard this can be quite a dangerous method to make use of because especially in this case it will action any text passed to it, but I don’t know of any other method to process the returned JSON string. Suggestions welcome.
I had this problem recently where I had a series of links which triggered a JQuery UI Modal dialog which when clicked was supposed to trigger an async-postback method which deletes an entry. The problem was the Modal Dialog.
First is the section with the modal dialog message and the button to trigger the postback.
It seemed that when I used the dialog, the click event occurred, but the async-postback did not occur.
However if I removed the dialog and just wrote the code to run one after another like below it worked as expected and triggered the button, though as you would expect minus the confirmation dialog.
As you could imagine, this was beginning to cause me headaches when I finally discovered after posting details about the problem on StackOverflow. The Modal Dialog only worked with a slight change of code. I needed to wrap the click event in a setTimeout() function. I’m not sure why this works, but it does.
Many thanks to @DanaBenson for his answer.
I have recently had the need to display content within a page of another page, using an iFrame. This is fine of the user interacts with the page as expected and the remote content will always appear in an iFrame, so my logic for closing the iFrame will always work. The problem is, I cannot guarantee the user will always be viewing the page from an iFrame, so I want to detect if the content is within the iFrame or not and act accordingly. I found out that it is surprisingly simple to do.
I came across this article today Dodgy Coder – Coding tricks of game developers.
Some of the things mentioned are genius like number 6. You wouldn’t like me when I’m angry – Nick Waanders
The solution took maybe an hour. A fellow programmer took four pictures of my face — one really happy, one normal, one a bit angry, and one where I am pulling my hair out. I put this image in the corner of the screen, and it was linked to the frame rate. If the game ran at over 30fps, I was really happy, if it ran below 20, I was angry.
After this change, the whole FPS issue transformed from, “Ah, the programmers will fix it.” to, “Hmm, if I put this model in, Nick is going to be angry! I’d better optimize this a little first.”
Others are scary and I would hope no sane developer would even attempt it like 1. The programming antihero – Noel Llopis
he explained to me that he had put aside those two megabytes of memory early in the development cycle. He knew from experience that it was always impossible to cut content down to memory budgets, and that many projects had come close to failing because of it. So now, as a regular practice, he always put aside a nice block of memory to free up when it’s really needed.
But my personal favourite is 4. Collateral damage – Jim Van Verth (@cthulhim)
Because the camera was using velocity and acceleration and was collidable, I derived it from our PhysicalObject class, which had those characteristics. It also had another characteristic: PhysicalObjects could take damage. The air strikes did enough damage in a large enough radius that they were quite literally “killing” the camera.
Check out the article Dodgy Coder – Coding tricks of game developers and also The Promise of HTML5 which shows some of the awesome abilities of the HTML5 Canvas element with WebGL.
The CSS property display is a very handy attribute which can easily allow you to structure content which would not logically be table content in a table structure. The reason for doing this is simple, under the w3c guidelines for the Semantic Web, a table should contain tabular data, not be used for structuring a page. Which is fine, because the CSS framework has
Which allows you to visibly structure in a table structure without using tables, brilliant. There is however one caveat, IE7 and below does not have full support for the display property, it only understand the types inline, block, and none. Which means that if you were to use display:table-cell; IE7 would revert to display:block; and potentially ruin your well laid plans.
But wait! jQuery to the rescue!!
This simple piece of code will, if the browser is IE7, grab the elements and wrap them in actually table elements which is a wonderfully simple solution, to achieve a visual layout without having to re-write all of your code to suit the situation.
However there was a minor problem, one of the controls only did a partial page postback to toggle the status of one of the fields. No Problem, Use UpdatePanelAnimationExtender, however this is a bit overkill for what I was intending.
All I needed was
The only problem I was having was I initially has the code as a self-executing function, styled after the jQuery source code which does the same. That would mean I would not need the $(document).ready() section as below:
But this would not work as it cannot call the function anymore, so I had to break it out of the self-executing block.
Whilst searching for what I would do to implement an electronic signature into a web application I came across this brilliant jQuery plugin by Thomas J Bradley which you should seriously look into if you are going to attempt this. It uses a HTML5 Canvas element which allows a user to draw a signature on the screen, submit it and return the result to be displayed to the user. It’s great.