Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7828581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:24:20+00:00 2026-06-02T10:24:20+00:00

I am playing with Ember and I am trying to use jquery ui sortable.

  • 0

I am playing with Ember and I am trying to use jquery ui sortable. Here is the code I used before ember that worked just fine:

$("ul.photo_list").sortable({
axis: 'x, y',
dropOnEmpty: false,
//handle: '.handle',
cursor: 'crosshair',
items: 'li',
opacity: 0.9,
scroll: true,
update: function(){
  $.ajax({
    type: 'post',
    data: $(".photo_list").sortable('serialize'),
    dataType: 'script',
    complete: function(request){
    },
    url: '/admin/projects/photos/sort})
  }
});

Now with Ember I have this code but it sends undefined to the server:

// Project Model
App.Project = Ember.Object.extend({
  _id: '',
  title: '',
  info: '',
  testimonial: '',
  type: '',
  created_at: '',
  updated_at: '',
  photos: [],
  available_types: [
    {value: 'landscape', name: 'Landscape', selected: false},
    {value: 'remodel', name: 'Remodel', selected: true},
    {value: 'new', name: 'New', selected: false}
  ],
  formattedDate: function () {
    return (new Date(this.get("created_at"))).toDateString();
  }.property("created_at"),
  formattedType: function () {
    return this.get("type").charAt(0).toUpperCase() + this.get("type").slice(1);
  }.property("type"),
  isPhotos: function () {
    var photos = this.get("photos");
    if (photos.length > 0) {
      return true;
    } else {
      return false;
    }
  }.property("photos")
});

App.currentProject = App.Project.create();

// Project Controller
App.projectsController = SC.ArrayController.create({
  content: [],
  loadProject: function(id) {
    var self = this;
    $.ajax({
      url: '/admin/projects/' + id,
      dataType: 'json',
      success: function(data) {
        if (data.photos) {
          data.photos = data.photos.map(function(photo) {
            return {
              _id: photo._id,
              photo: photo.photo,
              position: photo.position,
              thumb_url: '/assets/thumb_' + photo.photo,
              large_url: '/assets/large_' + photo.photo
            };
          });

        } else {
          data.photos = [];
        }
        App.currentProject.setProperties(data);
      },
      error: function() {
        console.log('Error')
      }
    });
  },
  createProjectFromJSON: function(json) {
    return App.Project.create(json);
  }
});

// View
App.ProjectView = Ember.View.extend({
  templateName: "projectShow",
  isPhotosBinding: "App.currentProject.isPhotos",
  photosBinding: "App.currentProject.photos",
  projects: function() {
    if (App.projectPagination.page <= 1) {
      Ember.routes.set('location', '!/projects');
    } else {
      Ember.routes.set('location', '!/projects?page=' + App.projectPagination.page);
    }
  },
  newProject: function() {
    Ember.routes.set('location', '!/projects/new');
    App.Router.project_new();
  },
  editProject: function() {
    App.currentProject.set('isEditing', true);
    return false;
  },
  didInsertElement: function() {
    console.log(App.currentProject.photos);
    this._super();
    this.$().sortable({
      items: 'li',
      opacity: 0.85,
      update: function(){
        console.log(App.currentProject.get('photos'));
        $.ajax({
          type: 'post',
          data: $("ul.photo_list").sortable('serialize'),
          dataType: 'script',
          complete: function(request){
          },
        url: '/admin/projects/' + App.currentProject._id + '/photos/sort'})
      }
    });
  }
});

I am still trying to find my way around Ember so any improvements are much appreciated. I am just not sure how I am suppose to update the position/order of App.currentProjects.photos so I can send that to the server to update the position because serializing ul.photo_list sends undefined back to the server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:24:22+00:00Added an answer on June 2, 2026 at 10:24 am

    Schedule the ajax call at the end of the RunLoop. In this way you know that the DOM was updated.

    Ember.run.schedule('timers', function () {
        $("ul.photo_list").sortable({
            axis: 'x, y',
            dropOnEmpty: false,
            //handle: '.handle',
            cursor: 'crosshair',
            items: 'li',
            opacity: 0.9,
            scroll: true,
    
            update: function(){
                $.ajax({
                type: 'post',
                data: $(".photo_list").sortable('serialize'),
                dataType: 'script',
                complete: function(request){
                },
                url: '/admin/projects/photos/sort'
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing with jquery for the first time, and I'm trying to get a simple
I'm having some issues with a jQuery AJAX call. My code works fine when
I am trying to create a jQuery content slider that will stop when a
Playing around with Python - tkInter - Entry widget - when I use validatecommand
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
I am trying to embed a sound in an auction website. I want that
At the end of playing a video, the jwplayer displays a share UI that
As stated here im trying to embed the dlls in the exe application in
I am trying to get an event to fire when a movie finishes playing.
I'm trying to write a simple component that will allow you to embed one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.