backbone.js - how to stop jQuery(html) download inner images and resources -


i'm trying make jquery-mobile + phonegap app simplified version of sites. approach deadly simple. build model , collections site , override parse() fill them. here goes code it.

var posts = backbone.collection.extend({  model: post, parse: function(response){     var posts = [];     var $response = $(response);     var $tr = $response.find('div.board_main tr');     $tr.each(function(index){         if(index<2){ return; } // skip notice post         var $post = $(this);         var post_id = $post.find('td').eq(0).text();         var $post_subject = $post.find('td.post_subject');         var post_subject;         if( $post_subject.find('a').length ){             post_subject = $post_subject.find('a').text();         }else{             return;         }         posts.push({             id: post_id,             subject: post_subject          });     });     return posts; } 

});

yes i'm using jquery parse html make model wrap response html $, @ time, browser download assets img, scripts in html didn't append somewhere in body.

how can cancel behavior? or should choose approach parse html?

==

edit: chose preprocessing avascript regexp before wrapping jquery. (remove iframe/script tags , replace img.src ok go ahead) know dirty safari won't download assets.. happy now.. :)

function removetag(html, tag){         var re = new regexp('<'+tag + '(.+?)' + '</'+tag+'>', 'g');         return html.replace(re,''); } function removeimgsrc(html){     return html.replace(/<img([^>]*)\ssrc=/gi,'<img$1 data-src=');     } 

see own related question: parsing invalid html jquery, without adding dom?

parsing html jquery causes resources images loaded because uses dom action. answer use approach.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -