|
I've got a setup where there's a large image, with a bunch of thumbnails below it. Currently, I'm using bootstrap to shrink the full sized images to thumbnails. I'm using a click event to load the thumbnail image, full size, where the current large image is. My question is, if I actually modify all the thumbnails resized by bootstrap into actual thumbnails, would that only load the full sized image if someone clicked on the thumbnail? If true, I'm guessing this is a good way to get the webpage to load much quicker? (Hopefully this all makes sense, I've been coding for several hours now...about to go to bed.)
|
# ? Apr 10, 2015 05:29 |
|
|
# ? May 5, 2024 00:13 |
|
If you're just resizing the full size images down to whatever you consider thumbnail sized, it's already downloading the full image anyway. Open up the Network tab in developer tools (just assuming you're in Chrome) and refresh the page to see the files downloaded by the browser. Ideally, you cut thumbnail sized images and store them on the server too. Store a data attribute (like <img data-full="path/to/fullsize.jpg" src="path/to/thumbnail.jpg" />) and then write a helper function where on click, it changes the source of the full size image container to the data attribute's value of the thumbnail you clicked on.
|
# ? Apr 10, 2015 06:22 |
|
hedgecore posted:If you're just resizing the full size images down to whatever you consider thumbnail sized, it's already downloading the full image anyway. Open up the Network tab in developer tools (just assuming you're in Chrome) and refresh the page to see the files downloaded by the browser. Here's the webpage in question now that I've got it setup: http://travisbumgarner.github.io/projects.html As an example, for senior design project, those first six "thumbnails" are actually the full sized images modified using bootstrap. There's jQuery on the page to run: code:
|
# ? Apr 10, 2015 20:41 |
|
Yep, that assumption is correct. If you just scale down the full size images for the thumbnails using CSS (bootstrap in this case), though, it will download all of the full size images every time you load the page. If you serve separate thumbnail files, it will be more requests but the initial page load will be much faster. Though there will be a moment's delay when you click an image (to download the full size version). As for the data attribute suggestion, it's so instead of writing this: code:
Here are the two changes you'd have to make: 1. Add 2 data attributes to each of the thumbnail image tags - "data-src" for the path to the full-size image in the thumbnail, and "data-target" for where the image should display. code:
code:
|
# ? Apr 11, 2015 18:35 |
|
darthbob88 posted:That would work, and next time the problem comes up I'll have to try it. Yell at them to only load jquery once. If you set a globally scoped variable like "$" and then it gets set to something else later, there's nothing you can do to tell it to use the "other version" of that variable, as it is long gone (overwritten that is). Your other option of course is to modify the offending plugin to work better with the various versions of jquery they might have loading, but that is going to be a pain in the rear end to maintain.
|
# ? Apr 12, 2015 04:11 |
|
subx posted:Yell at them to only load jquery once. That's what I thought, thanks for the confirmation and justification for yelling at clients. As many problems as I have at work, it's always nice to find things that somebody else needs to fix.
|
# ? Apr 12, 2015 11:20 |
|
darthbob88 posted:That would work, and next time the problem comes up I'll have to try it. You could do something like if (!$('#obj').plugin) {$.fn.plugin = someFunctionFromSomewhere;} if you want to support this scenario.
|
# ? Apr 15, 2015 03:28 |
|
I have a basic sortable listcode:
Pretty new to this so not sure if this is possible, or if this is something that's super easy. Have been looking on the sortable site but nothing has popped up.
|
# ? Apr 22, 2015 16:14 |
|
idontcare posted:I have a basic sortable list You just need to trigger an event whenever something gets dropped into sortable2 that looks for its "attached" field and moves it to the sortable2 element. If you are using some sort of drag and drop plugin, it should have a callback that fires when you drop, just check to see if it is now in the sortable2 element. Not hard to do but I can't write the code on a phone.
|
# ? Apr 22, 2015 18:14 |
|
subx posted:You just need to trigger an event whenever something gets dropped into sortable2 that looks for its "attached" field and moves it to the sortable2 element. Thanks for the reply. I've been googling and screwing around with this and have something that appears to work: code:
|
# ? Apr 22, 2015 20:52 |
|
JavaScript-wise the code is perfectly fine, but I want to steer you away from two specific things:
I'd personally do something more like this: https://jsfiddle.net/rngv2fow/4/ The biggest change is obviously how the HTML now defines the data relationship between items. code:
This way if your data or dependencies get modified, you only have to modify the HTML, which fully represents the data of the item, and the logic of the JavaScript is only responsible for resolving and handling the dependencies. A clear separation between data and logic. The code also uses data-container="sortable-items" to define the HTML containers that are sortable. This is another separation of simple JS selectors from CSS styles. I also refactored the code to jQuery plugin style, but that's just because I wanted to define all the parameters outside the function, making the code reusable. Fun things to try at home:
|
# ? Apr 25, 2015 04:53 |
|
I have an element defined in my HTMLcode:
Do I need to wait for some sort of event to let me know when the browser is done positioning poo poo? If I call position() later (in my event loop, for example) it gives me the expected result.
|
# ? Apr 25, 2015 19:56 |
|
You mean like $(document).ready(), or what? If not, is it possible for you provide an example, preferably on jsfiddle.net?
|
# ? Apr 26, 2015 06:20 |
|
IIRC, there's weirdness between browsers for .offset(), .position(), and probably others, mostly because of position styles (absolute, fixed, none). So if .position() is broken, try .offset() or .offsetParent(). You'll probably have to add more math on nearby elements as a result.
|
# ? Apr 26, 2015 19:47 |
|
code:
|
# ? May 22, 2015 21:44 |
|
huhu posted:
Maybe the .not() function? code:
|
# ? May 22, 2015 22:05 |
|
caiman posted:Maybe the .not() function? Awesome thanks. Think it'd be a bit complicated to assign unique classes for all of them. Unless I'm missing some feature of jQuery.
|
# ? May 23, 2015 00:26 |
|
*Ignore my poorly worded ramblings, I found a solution.
Hughmoris fucked around with this message at 04:10 on Jun 26, 2015 |
# ? Jun 26, 2015 01:19 |
|
I was having some trouble, so perhaps someone can tell me where i'm going wrong. I have a list of about 20 ajax links. Each link opens up a specific div. Sorta like a MORE INFO div. You click on div 1, goes to a controller, and it opens div-MoreInfo-1 with the new information, etc Okay, that works. Now, what I would like to do is have an "open all" button, that when clicked, will open each of the ajax links. I thought i could run a trigger on each link and open them up, but what ends up happening on Chrome and Firefox is that it stops after about the 13th link. (It opens 13 links and then opens nothing else.) On Safari, it opens all of them up correctly. I thought maybe it's hitting the controller function too fast, so I put a delay of 3 seconds, thinking that may be the problem, but it still opens all the links rather fast and quits after the 13th. my OpenAll button code looks like this. I didn't put all the trigger links, only a few. code:
|
# ? Jul 1, 2015 18:42 |
|
Maybe the ajax calls are failing for some reason? Check the dev tools network tab and see if theyre all giving the expected response and that theres 20 of them. Or perhaps not all the elements with click events being triggered exist? If that's the case, it might be simpler to give each div a common class and then triggering the click on $(".piss") or whatever the class name is to make sure theyre all being hit.
|
# ? Jul 2, 2015 04:01 |
|
obstipator posted:Maybe the ajax calls are failing for some reason? Check the dev tools network tab and see if theyre all giving the expected response and that theres 20 of them. i checked the dev tools and i see that 7 of them, the url fails. But when i rightclick and open the url, it works. Does Ajax or php timeout if being hit pretty quickly?
|
# ? Jul 2, 2015 15:29 |
|
stoops posted:i checked the dev tools and i see that 7 of them, the url fails. What's the error? Is a cross-domain request involved, perhaps? https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
|
# ? Jul 3, 2015 05:38 |
|
I have a simple line of jquery code that is supposed to reload part of the opened page when you click on an element. It works just fine except this part of the page that should be reloaded has it's own embedded jquery scripts and they are not run with the partial reload, so those parts go blank instead of changing. What can I do to also get the scripts to reload? Simplified the relevant code looks like this: code:
|
# ? Feb 22, 2016 12:50 |
|
His Divine Shadow posted:I have a simple line of jquery code that is supposed to reload part of the opened page when you click on an element. It works just fine except this part of the page that should be reloaded has it's own embedded jquery scripts and they are not run with the partial reload, so those parts go blank instead of changing. What can I do to also get the scripts to reload? Do you control that part of the page on the server end, too? If so, you should probably move that code out of that part of the page and run it in .load's callback. You could also make it self-executing, but that's a kludge. If you don't control that part of the page, you're going to need to call the code from the callback, anyway.
|
# ? Feb 22, 2016 15:58 |
|
I got it working using this example from stack overflow: https://stackoverflow.com/a/7330106/1005173 Plonked in that bit of code after the load and tweaked it to suit. Works!
|
# ? Feb 23, 2016 10:24 |
|
I'm no javascript or jquery expert but I do a pretty good job of figuring things out. I have a group of radio buttons, when certain ones are selected, a textarea field is displayed. I figured out how to display the field when the proper radio buttons are selected but I have an issue with displaying the field when a radio button is checked by default. This is my change function and it works great. If I appended .change() to it, it doesn't work for the radio that is selected by default. code:
code:
How do I combine the two to accomplish what I want? Or, better yet, what's the best practice method to accomplish onChange behavior along with setting a default value for a radio group?
|
# ? Feb 25, 2016 16:37 |
|
I think you could probably just tack on a .click() or a .trigger('click') to the selector once the change function has been bound.
|
# ? Feb 26, 2016 02:53 |
|
hedgecore posted:I think you could probably just tack on a .click() or a .trigger('click') to the selector once the change function has been bound. Goddamnit, I wasted way too much time on this. Thanks for the suggestion, that did exactly what I wanted. Edit: nevermind, it didn't work. It just selects the last option, not the active one. mooky fucked around with this message at 05:21 on Feb 26, 2016 |
# ? Feb 26, 2016 03:14 |
|
Calling code:
|
# ? Feb 27, 2016 01:08 |
|
I have 2 dropdowns that each call the same function.code:
I found two ways I could do this, both console.logged up there. The first console.log gives me [Window] which is a huge array that I can't make sense of, and the second one gives me Undefined. I know this is probably an easy question, but any help is appreciated.
|
# ? Mar 2, 2016 19:16 |
|
Change your onchange to "changeResults(this);" and then change the logging to:code:
|
# ? Mar 2, 2016 19:43 |
|
kloa posted:Change your onchange to "changeResults(this);" and then change the logging to: Thanks, that worked. One quick question. In a php function, i dont have to pass a variable by doing this code:
|
# ? Mar 2, 2016 19:54 |
|
stoops posted:Thanks, that worked. JS function arguments are not required at the call site. JavaScript code:
|
# ? Mar 2, 2016 20:58 |
|
I am trying to implement a find and replace for a table and was wondering how can I select the rows, and then update the specific pieces of data. The user will pick which column they want to search, and then provide From/To values. The catch is that there is generally a secondary field I have to update based on which value they are changing to. For example: They need to be able to see column EIA and Frequency (EIA is ID, Frequency is Description). They want to mass update the EIA columns: replace EIA 1 with EIA 2, but the frequency record needs to change too. Example table: code:
I'm not really sure where to start! Any ideas?
|
# ? Apr 4, 2016 20:02 |
|
OK as it always goes, once you ask the question, you start getting ideas:code:
|
# ? Apr 4, 2016 20:23 |
|
Edit: nevermind.
huhu fucked around with this message at 21:11 on May 30, 2016 |
# ? May 30, 2016 21:03 |
|
I have a bunch of li's with different nodeids and different nodetexts.code:
|
# ? Dec 5, 2016 20:31 |
|
stoops posted:I have a bunch of li's with different nodeids and different nodetexts. code:
code:
|
# ? Dec 5, 2016 20:46 |
|
Munkeymon posted:
i tried to get the nodeid like so but my value keeps coming back undefined. value = $("li[data-nodetext='" + value + "']"); console.log(value.nodeid);
|
# ? Dec 5, 2016 21:02 |
|
|
# ? May 5, 2024 00:13 |
|
you need extra quotes around value e: nevermind! variable-width fonts make quotes hard to read YO MAMA HEAD fucked around with this message at 21:58 on Dec 5, 2016 |
# ? Dec 5, 2016 21:20 |