Structure link with json
This commit is contained in:
1 parent
a4d1c68299
commit
8ebfac2b99
13 files changed
+124
-136
No files matched your search
@@ -220,36 +220,25 @@ function pageSetting(id, edit) {
|
||||
};
|
||||
|
||||
function linkSetting(id, edit) {
|
||||
$linkKey = $('#pageslide .link-key');
|
||||
$linkUrl = $('#pageslide .link-url');
|
||||
$linkTitle = $('#pageslide .link-title'),
|
||||
$linkPublishedTrue = $('#link_is_published_true');
|
||||
_status = edit;
|
||||
if(_status) {
|
||||
$.ajax({
|
||||
url: 'link-setting.json',
|
||||
type: 'POST',
|
||||
url: "<%= Rails.application.routes.url_helpers.get_link_setting_json_admin_links_path %>",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: 'json',
|
||||
data: '{"id": ' + id + '}',
|
||||
data: {id: id},
|
||||
cache: false,
|
||||
})
|
||||
.done(function(data) {
|
||||
_linkData = data;
|
||||
$linkKey.val(data.key);
|
||||
$.each(data.url, function(index, val) {
|
||||
$linkUrl.eq(index).val(val)
|
||||
});
|
||||
$.each(data.title, function(index, val) {
|
||||
$linkTitle.eq(index).val(val)
|
||||
});
|
||||
data.public ? $linkPublishedTrue.prop('checked', true) : $linkPublishedTrue.prop('checked', false);
|
||||
$linkPublishedTrue.prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
|
||||
$.each(data.link, function(index, val) {
|
||||
if(val[0]) {
|
||||
$('.active-link').eq(index).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
|
||||
val[1] == 1 ? $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true) : $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true);
|
||||
};
|
||||
$.each(_linkData.link, function(index, val) {
|
||||
if(val[1]) {
|
||||
$('#pageslide .active-link.' + val[0]).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
|
||||
$('#pageslide .active-link.' + val[0]).find('input[type="radio"]').eq(val[2]).prop('checked', true);
|
||||
}
|
||||
});
|
||||
$('#pageslide').find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user