ajax-chosen icon indicating copy to clipboard operation
ajax-chosen copied to clipboard

URL attribute from data of HTML element

Open palodelincak opened this issue 12 years ago • 1 comments

Is possible to make universal .ajax-chzn-select class, which will be loading URL attribute from HTML element?

Something like this:

$(".ajax-chzn-select").ajaxChosen
    method: "GET"
    dataType: "json"
    url: $(this).data("url")
  , (data) ->
    terms = {}
    $.each data, (i, val) ->
      terms[val._id] = val.name + " <span class='slug'>(" + val.slug + ")</span>"
    terms

palodelincak avatar Sep 03 '12 08:09 palodelincak

That would not make sense for most peoples needs this is to specific. If you have trouble geting the data for the url try this

$(".ajax-chzn-select").each(function(){
    var $this = $(this);
    $this.ajaxChosen({
        type: 'GET',
        url: $this.data("url")
        dataType: 'json', 
        function(data){
            //your callback
        }
    });
});

MarkVaughn avatar Nov 15 '13 22:11 MarkVaughn