- Screen name: tistklehoff
tistklehoff's Profile
5 Posts
7 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- Hello all.
I've some tabs loaded dinamically with AJAX. BUT, my datasource have it's own images repository and it uses relative paths. So, I'm receiving from AJAX calls something like this <img src="/apps/images/XXXX.png" />
I'm trying to change these src attributes, but I can't wonder what is the correct place to do this.
I tried in beforeLoad event, change the images but, after that, I can't stop the default tabs load behavior and jQuery insert the original data content, overriding mine.
I also tried in load event, but the browser try to load images at the moment in which they are inserted (or transformed in html by a $(data) statement), so the browser gets some load errors I'd like to avoid.
How can I deal with this? What can I do to stop default insertion in beforeLoad event?
My code in beforeLoad event in tabs widget:
- beforeLoad: function(event, ui){
- if ($(">a", ui.tab).hasClass("with-images")){
- ui.jqXHR.done(function(data, textStatus, jqXHR) {
- data = data.replace(/<img /g, "<photo ");
- $data = $(data);
- $data.appendTo(ui.panel);
- $(data).find("photo").each(function () {
- $(this).replaceWith("<img src='" + $("#help").data("helpImages") + "?relativePath=" + $(this).attr("src") + "' /> ");
- });
- });
- }
- }
Thanks all in advance.
Regards.- 15-Nov-2012 06:33 AM
- Forum: Using jQuery
Hello all.
I have some problems with an ajax call that should be quite simple and now I'm completely lost, so any help would be great.
Ok, let's go:
I have a web page working at this moment, ok, and I use $.get() to load a table into it (html format), this is working ok too. When user clicks in <tr> tags, I use $.get() another time to get some more html data, including an image as an <img src=". . .">.
the server send me the image only if a user loaded it previously from an external 'admin site', or HTTP 204 code if requested image doesn't exist.
I have two problems: First all, I'm unable to bind a load event to my image, no matter how I do it.
I tried $("img").on(), $("img").live() and both with $("img", data). I tried also with an Image object. All this code is in $(function(){ . . . }).And the second one, How can I take the return code for an image from the load event? HTTP 204 will fire a load success event, as far as I read.
Does exist another way to proceed? If does, please, put me on the way.
My code:- $(function(){
- . . .
-
/*Works-result is my table, when I click in a tr.header, a tr.tab-content expands with new data*/
$("#works-result").on("click", "#table-works tr.tab-header", function (event) {
var $content = $(this).next("tr.tab-content"); -
/*If clicked tr has not loaded yet, load data into it.*/
if ($content.find("td div.detail").length == 0) { -
/*Calling my server to get html data for this tr*/
$.when($.get($content.attr("codwork"))).then(function (data) { -
/*I'm unable to make it work in any way!*/
$("img", data).live("load", function () { . . . });
//$("img", data).on("load", function () { . . . });
//$("img").live("load", function () { . . . });
//$("img").on("load", function () { . . . }); - //I tried it binding events out here, directly under $(function(){});
- $content.find("td").append(data);
- }, function () { alert("error") });
-
}
});
. . . - });
Regards.- 10-Feb-2011 06:46 AM
- Forum: Using jQuery
Hello all.
I have some jQuery.ajax() calls. It'is all the same but success function and I'd like get less code by taking all ajax calls in the same function.
But I need one additional parameter I am using later in the success function, for instance.
My actual code is like this:- jQuery.ajax(myParam){
- ...
- success: function(responseData){
- //do some stuff with responseData
- //do some stuff with myParam
- }
- ...
- }
and I'd like this:- jQuery.ajax(myParam, customFunction){
- ...
- success: customFunction //customFunction will be myFunctionX...
- ...
- }
- function myFunction1 (XMLHttpRequest, status, responseData, myParam){
- //do some stuff with responseData
- //do some stuff with myParam
- }
- function myFunction2 (XMLHttpRequest, status, responseData, myParam){
- //do some stuff with responseData
- //do some stuff with myParam
- }
- ...
But I can't manage to archieve that.
Can you help me? Any tips, web references or whatever info will be very appreciate.
Thanks a lot in advance.
Regards.
Tistklehoff
- 20-Dec-2010 02:54 AM
- Forum: Using jQuery Plugins
Hello all.
I'm working with images this time and I have this problem:
I'm using the special.event.load plugin as is in https://github.com/peol/jquery.imgloaded/raw/master/ahpi.imgload.js and I'm binding a load event for image resize.
I take image data 'inline', I mean, image data base64 coded received from server.
Here is my code:- //first all, include the special event load plugin:
- (function (jQuery) {
- jQuery.event.special.load = {
- add: function (hollaback) {
- if ( this.nodeType === 1 && this.tagName.toLowerCase() === 'img' && this.src !== '' ) {
- // Image is already complete, fire the hollaback (fixes browser issues were cached
- // images isn't triggering the load event)
- if ( this.complete || this.readyState === 4 ) {
- hollaback.handler.apply(this);
- }
- // Check if data URI images is supported, fire 'error' event if not
- else if ( this.readyState === 'uninitialized' && this.src.indexOf('data:') === 0 ) {
- jQuery(this).trigger('error');
- }
- else {
- //Here!!! Throws 'too much recursion' exception, but not all times
- jQuery(this).bind('load', hollaback.handler);
- }
- }
- }
- };
- }(jQuery));
- //my load binding
- jQuery("#my_image").bind("load", function(e){
- //resize new image loaded
- });
- //Processing data in the succesfull ajax call for image
- //Substitute src attrib content, I'm not removing the 'old' <img> tag
- jQuery("#my_image").attr("src", imagen);
Is this correct?
What is happening?
Thanks all in advance.
Regards.- Hello all.
I have some problems when I try to manipulate a piece of HTML loaded by jQuery.load() function.
Here is my code:
- var $popupCorreo= jQuery("<div id='mypopup'></div>");
- //loading html code into mypopup
$popupCorreo.load("mypopup_code.html"); - //setting mypopup display:none
$popupCorreo.hide();
- //appending to body (mypopup has position:absolute and max z-index)
jQuery("body").append($popupCorreo);
- //this button is in loaded code
jQuery("#button_1").bind("click", function(){ - //blah blah blah
});
- //want to change the text for button
- jQuery("#button_1").text("new text for button");
Ok, I append the loaded code and then, bind the event and change some text in a loaded button, but it does not work.
If I change my code, live instead of bind, events work correctly. I tried to debug with firebug on Firefox 3.5 and all works fine only if I set a breakpoint between load and bind lines.
It seems to be any type of delay while loading. Or am I wrong?
How can I manage with that delay?
I was trying to find any information at this forum, but I did not manage to find anything. if I missed any post with relevant information, please, tell me.
Thanks all in advance.
Regards.
- «Prev
- Next »
Moderate user : tistklehoff
© 2012 jQuery Foundation
Sponsored by
and others.


