开发者

adding the .val to the autocomplete

I am trying to implement this jQuery auto complete function but the problem is this i need the value of the previous input field. getting the value from the previous is easy, I just dont know how to add it to the call

the call for the previous value is on top of the document.ready and th开发者_开发技巧is doesnt get called when the user types

I NEED to pass it in with this serviceurl like this

song_path(value) 

but that fails

    $(document).ready(function(){
            value = $('#request_artist').val();
        $('#song_artist').autocomplete({
          serviceUrl: '<%= song_path() %>',
          minChars:1,
          width: 300,
          delimiter: /(,|;)\s*/,
          deferRequestBy: 0, //miliseconds
          params: { artists: 'Yes' },
        });
    });

So i basically need something like this

    $(document).ready(function(){
        $('#song_artist').autocomplete({
          serviceUrl: '<%= song_path() %>'$('#request_artist').val(),
          minChars:1,
          width: 300,
          delimiter: /(,|;)\s*/,
          deferRequestBy: 0, //miliseconds
          params: { artists: 'Yes' },
        });
    });

but this fails


You will not be able to use song_path helper, as it is rendered before getting to the browser, you can't call that function in the browser. Instead you need to write something like

serviceUrl: '/songs/' + $('#request_artist').val(),   

if $('#request_artist').val() returns the id.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜