2013-07-28 15 views
5

Sto facendo una funzione di selezione un'opzione che prende il aggiungere un URL dinamico unico e sostituisce ilSelezionare l'opzione - Sostituire e con regex

& 

con

& 

nell'URL.

Jquery

$("#pageSizeOptions").change(function() { 
    document.location.href = ('?ViewAction=View&ObjectID=1710211').replace(/(\?|&)(PageSize=[^&]+)(&|$)/, '$3') + $(this).val(); 
}); 

Perl Template (jQuery)

$("#pageSizeOptions").change(function() { 
    document.location.href = ('#Pager.URL').replace(/(\?|&)(PageSize=[^&]+)(&|$)/, '$3') + $(this).val(); 
}); 

RISULTATO:

http://fiddle.jshell.net/RFfXs/5/show/light/?ViewAction=View&ObjectID=1710211&PageSize=40 

RISULTATI ATTESI:

http://fiddle.jshell.net/RFfXs/5/show/light/?ViewAction=View&ObjectID=1710211&PageSize=40 

http://jsfiddle.net/RFfXs/5/

Chiunque può aiutare su cosa esattamente sto facendo male ..

risposta

0

Prova questa,

$("#pageSizeOptions").change(function() { 
    console.log(('?ViewAction=View&ObjectID=1710211').replace('&', '&') + $(this).val()); 
}); 

Fiddle